GNOME Bugzilla – Bug 630077
GDateTime week number support
Last modified: 2010-09-27 13:18:21 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
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.
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.