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 678031 - datetime: add to/from_iso_8601_string() utility functions
datetime: add to/from_iso_8601_string() utility functions
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.11.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-06-13 15:23 UTC by Oleksij Rempel
Modified: 2012-06-27 12:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[RFC] patch v1 (2.90 KB, patch)
2012-06-14 20:14 UTC, Oleksij Rempel
needs-work Details | Review
patch v2 (5.80 KB, patch)
2012-06-18 10:10 UTC, Oleksij Rempel
committed Details | Review

Description Oleksij Rempel 2012-06-13 15:23:42 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.
Comment 1 Tim-Philipp Müller 2012-06-13 15:31:20 UTC
YYYY-MM
YYYY-MM-DD
YYYY-MM-DDTHH:MMZ (Z for Zulu/UTC timezone)
Comment 2 Tim-Philipp Müller 2012-06-13 15:33:29 UTC
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.
Comment 3 Oleksij Rempel 2012-06-14 20:14:08 UTC
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 4 Tim-Philipp Müller 2012-06-14 20:42:17 UTC
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) { ... }.
Comment 5 Oleksij Rempel 2012-06-18 10:10:52 UTC
Created attachment 216662 [details] [review]
patch v2

new version. this includes constructor and parser.
Comment 6 Tim-Philipp Müller 2012-06-27 12:53:15 UTC
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