GNOME Bugzilla – Bug 589491
g_time_val_from_iso8601 doesn't handle some cases
Last modified: 2009-09-01 13:41:50 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.
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.
Created attachment 139072 [details] [review] More accurate version More accurate version of the previous fix.
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 "(".)
Created attachment 139117 [details] [review] Reworked version
Dan, does this look right to you now ?
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.