From 56b2fea146596a5c95796aeba8929b220757a0ed Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Fri, 27 Nov 2020 22:26:58 +1100 Subject: [PATCH] dev.: tz testing. --- dbLifeLog/main.cnf | 5 +++-- htdocs/cgi-bin/system/modules/Settings.pm | 7 ++++--- htdocs/cgi-bin/testSettings.pl | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index c110aad..c827908 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -26,8 +26,9 @@ Credential format:< , don't enable here using AU # Following is similar to AUTO_LOGIN setting above, and must be set. < <> diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index cc219ec..8d7b229 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -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; } diff --git a/htdocs/cgi-bin/testSettings.pl b/htdocs/cgi-bin/testSettings.pl index 09ea8d7..936b844 100644 --- a/htdocs/cgi-bin/testSettings.pl +++ b/htdocs/cgi-bin/testSettings.pl @@ -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 -- 2.34.1