glib1.3.5 : g_date_xxxx_week_of_year
- From: GHF <jean-noel guiheneuf wanadoo fr>
- To: "gtk-devel-list gnome org" <gtk-devel-list gnome org>
- Subject: glib1.3.5 : g_date_xxxx_week_of_year
- Date: Wed, 27 Jun 2001 10:18:10 +0200
Hi,
The g_date_get_sunday_week_of_year routine returns 0 if the day is
before the first Sunday of the year.
The g_date_get_monday_week_of_year routine returns 0 if the day is
before the first Monday of the year.
But the ISO 8601 rule is : The first week of the year is the week
containing the first Thursday.
See : http://personal.ecu.edu/mccartyr/aboutwdc.htm
Here is a patch.
Best regards.
Jean-Noel
*** gdate.c.old Wed Jun 27 09:46:11 2001
--- gdate.c Wed Jun 27 09:48:55 2001
***************
*** 364,371 ****
wd = g_date_get_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_get_day_of_year (d) - 1;
!
! return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
guint
--- 364,371 ----
wd = g_date_get_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_get_day_of_year (d) - 1;
! /* The first week of the year is the week containing the first Thursday */
! return ((day + wd)/7U + (wd < 4 ? 1 : 0));
}
guint
***************
*** 391,398 ****
wd = g_date_get_weekday (&first);
if (wd == 7) wd = 0; /* make Sunday day 0 */
day = g_date_get_day_of_year (d) - 1;
!
! return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
void
--- 391,398 ----
wd = g_date_get_weekday (&first);
if (wd == 7) wd = 0; /* make Sunday day 0 */
day = g_date_get_day_of_year (d) - 1;
! /* The first week of the year is the week containing the first Thursday */
! return ((day + wd)/7U + (wd < 5 ? 1 : 0));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]