ISO Calendar

From Jsorm

Jump to: navigation, search

Overview

The ISO calendar is very similar to the Gregorian calendar used as a standard around the world. Rather than the three-part year/month/date used by the Gregorian calendar, the ISO calendar uses the three-part year/week/day. They are defined as follows:

  • Year: This is normally the same year as the Gregorian year. However, at times it may be one year ahead of the Gregorian year during the last week of the Gregorian year, or one year behind the Gregorian year during the first week of the Gregorian year.
  • Week: This is the week in the year, from 1 to 52 or sometimes 53.
  • Day: This is the day of the week within the Week listed above. Day 1 is always Monday.

Thus, the Gregorian date of Wednesday, January 23, 2008, is referenced as 2008/4/3, the 3rd day (Wednesday) of the 4th week of the year 2008.

Usage

Because the ISO year is essentially the Gregorian year with a slight variant, the ISO calendar is not included as a separate loaded calendar in jsorm i18n. To use an ISO calendar, one uses the Gregorian calendar, but sets the additional fields of ISO_YEAR and ISO_WEEK_OF_YEAR. Because these are non-standard fields, they cannot be retrieved using the convenience functions of getYear() and getWeekOfYear(), but rather must use get("ISO_YEAR") and get("ISO_WEEK_OF_YEAR").

The following example show how to get ISO calendar information.

var cal = jsorm.Calendar.getCalendar(config);
cal.setYear(2008);
cal.setMonth(1);
cal.setDate(23);
cal.get("ISO_YEAR"); // 2008
cal.get("ISO_WEEK_OF_YEAR"); // 4
Personal tools