[tz] Regarding changes of time format the Philippines

Arati Sethy asethy at barracuda.com
Wed Nov 1 07:30:47 UTC 2017


Thank you Paul for a quick response.  When i set time_zone=>local, the perl prints correct time.
[root at 10.36.68.133] # ll /etc/localtime 
lrwxrwxrwx 1 root root 31 Oct 26 12:31 /etc/localtime -> /usr/share/zoneinfo/Asia/Manila
[root at 10.36.68.133] # cat test_tz.pl 
use DateTime;

my $dt = DateTime->now();
print "The current date and time : ", $dt->strftime('%Y-%m-%d %T %z')."\n";

my $dt = DateTime->now(time_zone=>"local");
print "The current date and time : ", $dt->strftime('%Y-%m-%d %T %z')."\n";
my $date = `date`;
print "$date \n";

[root at 10.36.68.133] # 
[root at 10.36.68.133] # perl test_tz.pl 
The current date and time : 2017-11-01 06:55:35 +0000
The current date and time : 2017-11-01 14:55:35 +0800
Wed Nov  1 14:55:35 +08 2017
 
[root at 10.36.68.133] #

Our main concern is we take epoch time and call unix localtime to translate the epoch time to local time. This is done in c which is giving wrong result now.

c code looks as follows

#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <syslog.h>

#include <sys/time.h> /* clude defn. of gettimeofday */
#include <sys/types.h>
u_int64_t sysMilliTime()
{
    struct timeval tv;
    u_int64_t timestamp = 0;

    if ( gettimeofday(&tv, NULL) == 0)
    {
        /* seconds elapsed since jan 1, 1970 */
        timestamp = (long long) tv.tv_sec;

        /* Convert into milli seconds */
        timestamp *= 1000;
        timestamp += tv.tv_usec/1000;
    }
    return timestamp;
}
int main()
{
u_int64_t time = sysMilliTime();
struct tm *evTime;
evTime = localtime(&time);
printf("epoch:%lld, gmtoff: %ld, TZ: %s\n",time,evTime->tm_gmtoff, evTime->tm_zone);
}

[root at 10.36.68.133] # ./a.out 
epoch:1509521131510, gmtoff: 0, TZ: 

[root at 10.36.68.133] # gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.3.2/configure --prefix=/opt/gcc-4.3.2 --libdir=/opt/gcc-4.3.2/lib64 --libexecdir=/opt/gcc-4.3.2/lib64 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-clocale=gnu --enable-languages=c,c++ --disable-libstdcxx-pch
Thread model: posix
gcc version 4.3.2 (GCC) 
[root at 10.36.68.133] # 

Please have a look and let me know your findings.

Thanks,
Arati
________________________________________
From: Paul Eggert <eggert at cs.ucla.edu>
Sent: Wednesday, November 1, 2017 12:03 AM
To: Arati Sethy
Cc: Time Zone Mailing List
Subject: Re: Regarding changes of time format the Philippines

I am not observing either problem on Fedora 26, which currently uses
tzdb 2017b and Perl 5.24.3. I ran the following shell commands. Please
try them on your platform. If they work for you, can you give examples
of similar shell commands that fail for you?

$ TZ=Asia/Manila date
Wed Nov  1 01:52:50 +08 2017
$ TZ=Asia/Manila perl -E'use DateTime; say
DateTime->now(time_zone=>"local")->strftime("%Y-%m-%d %H:%M:%S %z (%Z)");'
2017-11-01 01:53:22 +0800 (+08)
$ perl -E'use DateTime; say DateTime->VERSION;'
1.43
$ perl -E'use DateTime; say DateTime::TimeZone->VERSION;'
2.13

If I change "local" to "floating", I get symptoms similar to what you
report:

$ TZ=Asia/Manila perl -E'use DateTime; say
DateTime->now(time_zone=>"floating")->strftime("%Y-%m-%d %H:%M:%S %z
(%Z)");'
2017-10-31 17:57:03 +0000 (floating)

However, this is what "floating" is supposed to do, and it does the same
thing if TZ="America/Los_Angeles".

===========================================================
Learn how to protect users, data, and applications with security engineered for the public cloud by Barracuda. http://barracuda.com

DISCLAIMER:
This e-mail and any attachments to it contain confidential and proprietary material of Barracuda, its affiliates or agents, and is solely for the use of the intended recipient. Any review, use, disclosure, distribution or copying of this transmittal is prohibited except by or on behalf of the intended recipient. If you have received this transmittal in error, please notify the sender and destroy this e-mail and any attachments and all copies, whether electronic or printed.
===========================================================


More information about the tz mailing list