Re: RFC: should GMime use GDateTime instead of time_t?



Hi Jeff:

Am 27.03.17 15:28 schrieb(en) Jeffrey Stedfast via balsa-list:
When the timezone is "EDT" or "-0400", g_time_zone_new(const char *name) returns a GTimeZone just fine and I 
pass it off to g_date_time_new(), but if I then ask for the UTC offset from the GDateTime, I get back 0.

If I change the string to "EST" or "-0500", everything works perfectly and I get back exactly the UTC offset 
that I would expect (-5 hours).

I guess the GLib functions (like tzset) use the iana zone info data base (<https://www.iana.org/time-zones>).  On my 
Ubuntu 16.04 system it is living in the folder /usr/share/zoneinfo.  But there is no "EDT" (or other daylight 
saving, like CEST) definition file.

I wrote the tiny attached test app - passing "EDT" or "CEST" as 1st parameter fails as you described.  Passing "EST" or 
"CET" or *any* numerical offset, including "-0400", returns the proper result.  If the time zone names are given, of course depending upon 
the input date:

---8<----------------------------------------------------------------------------------
albrecht@deneb:~/Work$ ./gdatetimetest CET $(date +%s)
** Message: 1490643491 = 19:38:11 2017-03-27: interval 95: offset vs. UTC = 120 minutes
albrecht@deneb:~/Work$ ./gdatetimetest CET 1490000000
** Message: 1490000000 = 08:53:20 2017-03-20: interval 94: offset vs. UTC = 60 minutes
albrecht@deneb:~/Work$ ./gdatetimetest +0100 $(date +%s)
** Message: 1490643494 = 19:38:14 2017-03-27: interval 0: offset vs. UTC = 60 minutes
---8<----------------------------------------------------------------------------------

Do you get a different result when using the pure libc functions (i.e. set TZ, use tzset(), and then localtime())?  At 
least running the "date" command from the console with TZ set to a dst time zone will /also/ return UTC:

---8<----------------------------------------------------------------------------------
albrecht@deneb:~/Work$ TZ=CET date
Mo 27. Mär 21:53:22 CEST 2017
albrecht@deneb:~/Work$ TZ=CEST date
Mo 27. Mär 19:53:24 CEST 2017
albrecht@deneb:~/Work$ TZ=UTC date
Mo 27. Mär 19:53:37 UTC 2017
---8<----------------------------------------------------------------------------------

Hope this helps,
Albrecht.

Attachment: gdatetimetest.c
Description: Text Data

Attachment: pgpOxHnhRsM3i.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]