Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ISO-8601 week numbering vs "Outlook" numbering in PHP

I recently came across a big problem, as I have a system that's paying the customers weekly.

As we all know, a year has 52 weeks, and there are standards for it. I'm using PHP aka date('W') to get the week number from a date, that calculates that according to the standard ISO-8601.

Here are some references:

  • http://www.iso.org/iso/date_and_time_format and
  • http://en.wikipedia.org/wiki/ISO_week_date

But here's the ISSUE: year 2009 has 53 weeks. It seems that through the Gregorian calendar within 400 years there are 71 years that have 53 weeks. That's one thing I didn't know, and probably many didn't as well.

According to Wikipedia:

2009-12-31 is 2009-W53-4 (ISO year 2009 has 53 weeks, extending the Gregorian year 2009, which starts and ends with Thursday, at both ends with three days).

and the date function in PHP totally respects it.

If you look into MS Outlook, and show day of the week in the calendar view, it will appear 52 weeks considering 28 DEC 2009 to 03 JAN 2010 week 1. Is this another standard? The US standard or something?

If so, then why PHP can't support it? Did anyone make a function that supported this?

Is it correct to have 53 weeks? We have both European and US clients.

like image 562
PartySoft Avatar asked Feb 04 '10 18:02

PartySoft


People also ask

Why is Outlook week number wrong?

Depending on your locale / region you might have the non-ISO behaviour by default. To change it, go to System Preferences –> Language & Region –> Calendar and change it from Gregorian to ISO 8601 . This setting applies to other apps as well, such as Apple's Calendar.

What is ISO 8601 week based?

All weeks in the ISO-8601 Week-Based calendar have exactly 7 days, start on a Monday, and each week belongs to single year. Unlike the Gregorian calendar, there are no weeks that extend across years. Each ISO-8601 year is either a Long or a Short year, with 52 or 53 weeks depending on when the ISO-8601 year begins.

How are week numbers calculated?

The week number is the count of weeks that have passed in the year up to the end of the current week. For example, if it's the second week of the year, the week number is 2. The week where Jan 1 falls counts as the first week for the following year.


1 Answers

Outlook doesn't follow any sort of standard for week numbering. It has two settings that determine week numbering, called "First day of week" and "First week of year".

By setting "First day of week" to Monday and "First week of year" to "First 4-day week" the ISO standard can be simulated.

Each user will have to make this adjustment to follow the ISO standard.

I know of no separate US standard, and, apparently, neither does Outlook.

like image 178
Jeffrey L Whitledge Avatar answered Oct 12 '22 17:10

Jeffrey L Whitledge