Calendar issues

Norbert Lindenberg ecmascript at norbertlindenberg.com
Thu Sep 13 13:38:05 PDT 2012


The output of Date.prototype.toLocaleString and DateTimeFormat.prototype.format is also intended for normal people, not for techies. So why should we introduce a year 0 for them?

Norbert


On Sep 13, 2012, at 13:31 , Mark Davis ☕ wrote:

> In ICU, we are using Gregorian eras (AD/BC) as customarily interpreted, and there is no year zero. There isn't a simple way to get non-era years—and that form is mostly interesting to techies, not normal people, which is why we support the era form.
> 
> (If someone wanted to do it, you could probably get reasonable results by taking the input date, parsing with a calendar, and if the year < 1, set the year field to 1-year, get the date pattern for the locale, get the number pattern for a negative integer in the locale, insert the prefix/suffix around the year field in the date pattern, and format the Calendar date. That's be a dozen or two lines of code, but would need some extra code for exceptions.)
> 
> Mark
> 
> — Il meglio è l’inimico del bene —
> 
> 
> 
> On Thu, Sep 13, 2012 at 8:40 AM, Norbert Lindenberg <ecmascript at norbertlindenberg.com> wrote:
> 
> On Sep 13, 2012, at 6:55 , Andrew Paprocki wrote:
> 
> >>>> and Explorer formats it as being in the year 1 BC. Safari calculates the day
> >>>> according to the Julian calendar, all others use the proleptic Gregorian
> >>>> calendar.
> >
> > That is very surprising to me. Can anyone comment on why Safari chose
> > that implementation?
> 
> Probably because that's the default used for date and time formatting in ICU. ICU can be made to use a proleptic calendar by setting the Gregorian cutover to the beginning of time; I don't see an easy way to make it introduce a year 0.
> 
> Norbert
> 
> 



More information about the es-discuss mailing list