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 707151 - gdatetime: Extend the '%z' timezone format
gdatetime: Extend the '%z' timezone format
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-08-30 19:30 UTC by Kalev Lember
Modified: 2013-08-31 11:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdatetime: Extend the '%z' timezone format (4.62 KB, patch)
2013-08-30 19:31 UTC, Kalev Lember
none Details | Review
gdatetime: Extend the '%z' timezone format (4.78 KB, patch)
2013-08-30 20:01 UTC, Kalev Lember
committed Details | Review
Add tests for new '%z' g_date_time_format extensions (1.54 KB, patch)
2013-08-30 20:01 UTC, Kalev Lember
committed Details | Review

Description Kalev Lember 2013-08-30 19:30:45 UTC
Currently it's only possible to format the timezone offset in a very rigid way, g_date_time_format() only supports the +-XXXX format with %z, which for my timezone is +0200. It would be nice to be able to also get +02:00 or even just +2.

date(1) from coreutils has some strftime extensions for %z which would be nice to have in glib as well.
Comment 1 Kalev Lember 2013-08-30 19:31:47 UTC
Created attachment 253650 [details] [review]
gdatetime: Extend the '%z' timezone format

Implement the date(1) strftime extension for the '%z' numeric timezone
format:

%z     +hhmm numeric time zone (e.g., -0400)

%:z    +hh:mm numeric time zone (e.g., -04:00)

%::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)

%:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
Comment 2 Kalev Lember 2013-08-30 19:43:12 UTC
Some more digging revealed that the extended %z format is a gnulib extension that date(1) supports.
Comment 3 Kalev Lember 2013-08-30 20:01:41 UTC
Created attachment 253654 [details] [review]
gdatetime: Extend the '%z' timezone format

Implement gnulib strftime extensions for the '%z' numeric timezone
format. These are also supported and documented by GNU date(1):

%z     +hhmm numeric time zone (e.g., -0400)

%:z    +hh:mm numeric time zone (e.g., -04:00)

%::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)

%:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
Comment 4 Kalev Lember 2013-08-30 20:01:45 UTC
Created attachment 253655 [details] [review]
Add tests for new '%z' g_date_time_format extensions
Comment 5 Matthias Clasen 2013-08-31 00:04:05 UTC
Review of attachment 253654 [details] [review]:

Would be good to add a "Since 2.38", feel free to push with that addition
Comment 6 Matthias Clasen 2013-08-31 00:04:43 UTC
Review of attachment 253655 [details] [review]:

sure
Comment 7 Kalev Lember 2013-08-31 11:46:50 UTC
Thanks for the reviews!

I've added 'Since: 2.38' to the docs and an additional test for the 0 offset. The new test caught an issue with %:::z which I've fixed up as well.

Attachment 253654 [details] pushed as 8fd7f58 - gdatetime: Extend the '%z' timezone format
Attachment 253655 [details] pushed as 8d62c24 - Add tests for new '%z' g_date_time_format extensions