Skip to content

Commit

Permalink
webui: Fix timezone detection (RMerl#729)
Browse files Browse the repository at this point in the history
Ignore text in parentheses which may include a dash in non-English languages and confuse the index logic.  For example:

"GMT+0300 (Itä-Euroopan kesäaika)"

Fixes #726
  • Loading branch information
dave14305 committed Mar 27, 2021
1 parent a8b66a5 commit 73e5ec9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 8 additions & 5 deletions release/src/router/www/Advanced_System_Content.asp
Expand Up @@ -918,11 +918,14 @@ function corrected_timezone(){
var today = new Date();
var StrIndex;
var timezone = uptimeStr_update.substring(26,31);
if(today.toString().lastIndexOf("-") > 0)
StrIndex = today.toString().lastIndexOf("-");
else if(today.toString().lastIndexOf("+") > 0)
StrIndex = today.toString().lastIndexOf("+");
var startPos = today.toString().indexOf("(");
if ( startPos < 0 )
startPos = today.toString().length;
if(today.toString().lastIndexOf("-", startPos) > 0)
StrIndex = today.toString().lastIndexOf("-", startPos);
else if(today.toString().lastIndexOf("+", startPos) > 0)
StrIndex = today.toString().lastIndexOf("+", startPos);
if(StrIndex > 0){
//alert('dstoffset='+dstoffset+', 設定時區='+timezone+' , 當地時區='+today.toString().substring(StrIndex, StrIndex+5))
Expand Down
12 changes: 8 additions & 4 deletions release/src/router/www/state.js
Expand Up @@ -3620,10 +3620,14 @@ function switchType(obj, showText, chkBox){
function corrected_timezone(){
var today = new Date();
var StrIndex;
if(today.toString().lastIndexOf("-") > 0)
StrIndex = today.toString().lastIndexOf("-");
else if(today.toString().lastIndexOf("+") > 0)
StrIndex = today.toString().lastIndexOf("+");
var StrIndex;
var startPos = today.toString().indexOf("(");
if ( startPos < 0 )
startPos = today.toString().length;
if(today.toString().lastIndexOf("-", startPos) > 0)
StrIndex = today.toString().lastIndexOf("-", startPos);
else if(today.toString().lastIndexOf("+", startPos) > 0)
StrIndex = today.toString().lastIndexOf("+", startPos);

if(StrIndex > 0){
if(timezone != today.toString().substring(StrIndex, StrIndex+5)){
Expand Down

0 comments on commit 73e5ec9

Please sign in to comment.