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 630077 - GDateTime week number support
GDateTime week number support
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-09-19 15:24 UTC by Jürg Billeter
Modified: 2010-09-27 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jürg Billeter 2010-09-19 15:24:48 UTC
g_date_time_get_week_of_year uses week numbering according to ISO 8601. This makes sense, however, it should be noted in the documentation as some locales define other week numbering schemes.

The year used in ISO week dates doesn't always correspond to the year of the year-month-day scheme. GDateTime should provide a function to return the ISO week-numbering year¹.

As a side-note, the implementation of g_date_time_get_day_of_week could be simplified significantly. The algorithm from the Calendar FAQ is only as complex because it's based on year-month-day input. As we already have a day number, it should be as simple as:

        (datetime->days - 1) % 7 + 1

(0001-01-01 was a Monday)

¹ http://en.wikipedia.org/wiki/ISO_week_date
Comment 1 Jürg Billeter 2010-09-19 15:47:52 UTC
I forgot to mention that the documentation of g_date_time_get_day_of_week is wrong. It currently says "1 is Sunday, 2 is Monday, etc.", however, it returns ISO weekday numbers where 1 is Monday and 7 is Sunday.
Comment 2 Allison Karlitskaya (desrt) 2010-09-27 13:18:21 UTC
commit 9c0eb37adb14209e066bd25c6a3e27b0f698decc
Author: Ryan Lortie <desrt@desrt.ca>
Date:   Mon Sep 27 09:06:24 2010 -0400

    Bug 630077 - GDateTime week number support
    
    Fully implement support for ISO 8601 week dates in GDateTime and
    document that this is the case.
    
    Add an exhaustive test case to ensure correctness.