GNOME Bugzilla – Bug 649900
Add a function to return a display friendly representation of a time
Last modified: 2018-02-16 13:30:31 UTC
Empathy [1] and Totem [2] both have such functions, it would be good to have one in Glib. [1] http://git.gnome.org/browse/empathy/tree/libempathy/empathy-time.c#n87 [2] http://git.gnome.org/browse/totem/tree/src/properties/bacon-video-widget-properties.c#n144
I would also expect similar functions to be used in other media players (such as Rhythmbox, Banshee, etc.).
*** Bug 325064 has been marked as a duplicate of this bug. ***
I think there are several possible requests here: 1) Absolute time formatting (for example, ‘14:05:01 GMT’), which can be done with g_date_time_format(). 2) Relative time formatting (for example, ‘15 hours ago’ or ‘50 seconds ago’). 3) Duration formatting (the media player case, for example, ‘1 hour, 24 minutes’). As mentioned in bug #325064, this is a tricky topic for GLib. We had problems sorting out the disk size formatting functions to everyone’s satisfaction. I think, in general, it’s not possible to provide ‘human readable’ string formatting functions which are general enough to be applicable in enough applications, but not too general to be impossible to use. Media players and chat clients have different requirements, for example. Media players want to show the time remaining in a stream, or the duration of a stream, and are concerned with small numbers of seconds. Chat clients typically deal with relative times in the past, and don’t care about accuracy to the number of seconds. I think those are good reasons to keep formatting functions like this in the applications themselves. For the case of media applications, GStreamer might be able to provide something suitable for use by several applications. I don’t think GLib is the right place for this, though. ⇒ WONTFIX
(In reply to Philip Withnall from comment #3) > 3) Duration formatting (the media player case, for example, ‘1 hour, 24 > minutes’). We'd format that way for display in properties, but not in the media player itself. I filed bug 679850 against GStreamer a long time ago for that purpose though, which is a better place to have media player specific functionality.