poshest poshest - 29 days ago 17
AngularJS Question

AngularJS i18n: ngLocale FIRSTDAYOFWEEK and WEEKENDRANGE

Somewhere in the v1.4.0-betas, Angular i18n files acquired some new attributes like

DATETIME_FORMATS.FIRSTDAYOFWEEK
. Latest version as of now.

Does anyone understand how
FIRSTDAYOFWEEK
and
WEEKENDRANGE
work? From my observation, here's what I think was intended


  1. DATETIME_FORMATS.DAY
    always starts on Sunday (consistent with 0 = Sunday in javascript), no matter what day of the week is considered the first day of the week in that locale

  2. DATETIME_FORMATS.FIRSTDAYOFWEEK
    should indicate the first day of the week in the locale, so that if it's 0, the week starts on Sunday, 1 = Monday and so on.

  3. DATETIME_FORMATS.WEEKENDRANGE
    should be the days of the week that are considered weekend days in the locale



My problems are that


  • DATETIME_FORMATS.FIRSTDAYOFWEEK
    for en-au is
    6
    . That would be Saturday, and the first day of the week isn't Saturday here in Australia (they argue about Sunday or Monday being the start)

  • DATETIME_FORMATS.WEEKENDRANGE
    for en-au is
    [5, 6]
    and Friday isn't a weekend day here either (despite the fact that workers slack off and drink beer in the afternoons).



So are there just a bunch of errors in the files? Or do I not understand the scheme being implemented here?

Answer

For ngLocale files, "Monday is day 0 as specified by ISO-8601"

...as opposed to Javascript, where Date.prototype.getDay() returns 0 for Sunday. Watch out!

I asked for this to be added to the documentation.

Comments