GNOME Bugzilla – Bug 678031
datetime: add to/from_iso_8601_string() utility functions
Last modified: 2012-06-27 12:54:18 UTC
Some tag parsers and writers use same datetime format based on ISO 8601. For example vorbis tag should use some thing like this: YYYY-MM-DDTHH:MM:SS+TS the xmp uses: YYYY-MM-DDTHH:MM:SS.%15USEC+TS id3tag: YYYY We can reduce some code by creating some general functions for it.
YYYY-MM YYYY-MM-DD YYYY-MM-DDTHH:MMZ (Z for Zulu/UTC timezone)
There's some code you could build on top of in check_release_datetime() on gstplugin.c, otherwise also in GLib for GDate and GDateTime of course.
Created attachment 216458 [details] [review] [RFC] patch v1 This is first version. I need to decide what to do with fraction of second. How precise should it be and should i do extra constructor for it?
Comment on attachment 216458 [details] [review] [RFC] patch v1 What I had in mind was slightly different, and should be even easier: I think we should just have two functions, let's name them: gst_date_time_new_from_iso8601_string(), and gst_date_time_to_iso8601_string() (or just _to_string() and new_from_string() - to be determined) The _to_...string() function should serialise to the most compact form possible IMHO, depending on which fields are valid. The DateTime knows which fields are not set, so it can pick the right function itself instead of letting the caller decide. So in effect _to_..string() should just be what string_check is now, with a switch(datetime->fields) { ... }.
Created attachment 216662 [details] [review] patch v2 new version. this includes constructor and parser.
commit f95996d97f1692ae59e9f9d305ee8d922fa25d78 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Wed Jun 27 13:19:23 2012 +0100 tests: add some datetime serialisation/deserialisation tests https://bugzilla.gnome.org/show_bug.cgi?id=678031 commit 5a6be2201dd4af0a57f634be90ed264d9ab4392d Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Wed Jun 27 13:16:07 2012 +0100 datetime: fix compare function Take into account that not all fields might be valid (though they are valid in the GDateTime structure). But we should just return unordered if the set fields don't match. Also, don't check microseconds when comparing datetimes, since we don't serialise those by default if they're available. This ensures date times are still regarded as equal after serialising+deserialising. commit 1eb9932dbbdfb8aa569d7e67bf68e47f2ddfb3b3 Author: Oleksij Rempel <bug-track@fisher-privat.net> Date: Mon Jun 18 08:06:49 2012 +0200 datetime: add serialisation to and deserialisation from ISO 8601 strings Some tag parsers and writers use same datetime format based on ISO 8601. We can reduce some code by creating some general functions for it. API: gst_date_time_to_iso8601_string() API: gst_date_time_new_from_iso8601_string() https://bugzilla.gnome.org/show_bug.cgi?id=678031