After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 589491 - g_time_val_from_iso8601 doesn't handle some cases
g_time_val_from_iso8601 doesn't handle some cases
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-07-23 12:45 UTC by Andy Shevchenko
Modified: 2009-09-01 13:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch. (2.39 KB, patch)
2009-07-23 12:48 UTC, Andy Shevchenko
none Details | Review
More accurate version (2.53 KB, patch)
2009-07-23 13:06 UTC, Andy Shevchenko
needs-work Details | Review
Reworked version (3.43 KB, patch)
2009-07-23 22:13 UTC, Andy Shevchenko
none Details | Review

Description Andy Shevchenko 2009-07-23 12:45:41 UTC
Please describe the problem:
ISO 8601:2004 allows to use format without any timezone specification.
In such case the local timezone is implies (see 4.2.5.2).


Steps to reproduce:
Take into consideration the following date:
1980-02-22T10:36:00

Actual results:


Expected results:


Does this happen every time?
Every time.

Other information:
Patch is attached.
Comment 1 Andy Shevchenko 2009-07-23 12:48:02 UTC
Created attachment 139070 [details] [review]
Proposed patch.

The proposed patch is made against HEAD of the git repository of glib. It could be applied by git am command.
Comment 2 Andy Shevchenko 2009-07-23 13:06:48 UTC
Created attachment 139072 [details] [review]
More accurate version

More accurate version of the previous fix.
Comment 3 Dan Winship 2009-07-23 13:35:51 UTC
Your patch treats a timestamp with no offset as being UTC, not local time. You probably want to postpone the mktime_utc() call until after you've parsed the timezone part, and then if there's an offset (or "Z"), call mktime_utc() and apply the offset to it, but if there isn't an offset, call plain mktime().

Also, to test this properly in testglib, you need to worry about the time zone of the person running testglib... easiest fix might be to forcibly override the timezone to a known value (g_setenv("TZ", "something", TRUE); tzset();).

(Also, watch out for code style; there should be a space between "g_ascii_isspace" and the following "(".)
Comment 4 Andy Shevchenko 2009-07-23 22:13:47 UTC
Created attachment 139117 [details] [review]
Reworked version
Comment 5 Matthias Clasen 2009-09-01 02:46:01 UTC
Dan, does this look right to you now ?
Comment 6 Dan Winship 2009-09-01 13:41:50 UTC
The attached patch broke "Z" (it parsed it as local time rather than UTC, which would make testglib fail unless you happened to run it in a UTC+0 timezone). I reworked it some and committed it.