DateTime.getWeekNumberingYear

Returns the ISO 8601 week-numbering year in which the week containing @datetime falls.

This function, taken together with g_date_time_get_week_of_year() and g_date_time_get_day_of_week() can be used to determine the full ISO week date on which @datetime falls.

This is usually equal to the normal Gregorian year (as returned by g_date_time_get_year()), except as detailed below:

For Thursday, the week-numbering year is always equal to the usual calendar year. For other days, the number is such that every day within a complete week (Monday to Sunday) is contained within the same week-numbering year.

For Monday, Tuesday and Wednesday occurring near the end of the year, this may mean that the week-numbering year is one greater than the calendar year (so that these days have the same week-numbering year as the Thursday occurring early in the next year).

For Friday, Saturday and Sunday occurring near the start of the year, this may mean that the week-numbering year is one less than the calendar year (so that these days have the same week-numbering year as the Thursday occurring late in the previous year).

An equivalent description is that the week-numbering year is equal to the calendar year containing the majority of the days in the current week (Monday to Sunday).

Note that January 1 0001 in the proleptic Gregorian calendar is a Monday, so this function never returns 0.

class DateTime
int
getWeekNumberingYear
()

Return Value

Type: int

the ISO 8601 week-numbering year for @datetime

Meta

Since

2.26