]> lifelog.hopto.org Git - LifeLog.git/commitdiff
dev.: tz testing.
authorWill Budicm <redacted>
Fri, 27 Nov 2020 11:26:58 +0000 (22:26 +1100)
committerWill Budicm <redacted>
Fri, 27 Nov 2020 11:26:58 +0000 (22:26 +1100)
dbLifeLog/main.cnf
htdocs/cgi-bin/system/modules/Settings.pm
htdocs/cgi-bin/testSettings.pl

index c110aad59c1ebbaf086a7df4e215e28a3b45fae1..c8279085b21d7991e10ef8153d0d6329d8dfa920 100644 (file)
@@ -26,8 +26,9 @@ Credential format:<<AUTO_LOGIN <{alias}/{password}> , don't enable here using AU
 # Following is similar to AUTO_LOGIN setting above, and must be set.
 <<!PUBLIC_LOGIN<admin/admin>
 <<TIME_ZONE_MAP<
-Marsfield=Australia/Sydney
-Bondi=Australia/Sydney
+Australia/Marsfield=Australia/Sydney
+Australia/Bondi=Australia/Sydney
+America/Austin=America/Chicago
 America/Texas=America/Chicago
 >>
 
index cc219ec49ff0e63863500591f552dc21bcceeb11..8d7b229e593463d3dc953116b4bc5068ec324813 100644 (file)
@@ -171,20 +171,21 @@ sub today {
 
 sub setTimezone {    
     my $ret = shift;
+    my $to  = shift; #optional for testing purposes.
     my $v= $anons{'TIME_ZONE_MAP'};
     if($v){
        if(!%tz_map){
            %tz_map={}; chomp($v);
-           foreach (split('\n')){
+           foreach (split('\n',$v)){
              my @p = split('=', $_);
              $tz_map{trim($p[0])} = trim($p[1]);
            }
        }
-       $v = $tz_map{$TIME_ZONE}; #will be set in config to either valid or mapped.
+       if($to){$v = $tz_map{$to};}else{$v = $tz_map{$TIME_ZONE};}      
        if($v){$TIME_ZONE=$v}
     }
     $ret = DateTime->now() if(!$ret);
-    $ret -> set_time_zone($TIME_ZONE) ;
+    $ret -> set_time_zone($TIME_ZONE);
     return $ret;
 }
 
index 09ea8d7d3c69d78799614e4422cafd1d43d1f878..936b844023906d66b58c32cb943692139498654e 100644 (file)
@@ -20,11 +20,13 @@ require CNFParser;
 my $cnf = CNFParser->new($ENV{'PWD'}.'/dbLifeLog/main.cnf');
 my $ptr = $cnf->anons();
 Settings::anonsSet($ptr);
-
-my $time  = Settings::today();
+my $time = Settings::today();
+my $cnf_tz = Settings::timezone();
+my $ret = Settings::setTimezone(undef, 'America/Texas');
 my $a = Settings::anon('TIME_ZONE_MAP');
 
 
-print $time, $a , "\n";
+
+print "tz:".$cnf_tz." time:". $time. "\n", $a , "\n\nTime America/Texas:$ret\n";
 
 1;
\ No newline at end of file