Hi Bruno,

Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes:

> This patch adds proper support for the non-Gregorian calendars in use in
>   - Thailand,
>   - Iran,
>   - Ethiopia,
> to the 'nstrftime' module and, with it (automatically) to the GNU coreutils
> 'date' program (for output).
>
> Why is this needed? Because these countries don't use the Gregorian calendar
> primarily.
>
>   * Thailand:
>     https://en.wikipedia.org/wiki/Thai_calendar says
>     "In Thailand, two main calendar systems are used alongside each other:
>      the Thai solar calendar, based on the Gregorian calendar and used for
>      official and most day-to-day purposes, and ..."
>
>   * Iran:
>     https://en.wikipedia.org/wiki/Solar_Hijri_calendar says
>     "The Solar Hijri calendar is the official calendar of Iran."
>     https://en.wikipedia.org/wiki/Solar_Hijri_calendar#Iran says
>     "The present Iranian calendar was legally adopted on 31 March 1925"
>     
> https://en.wikipedia.org/wiki/Iranian_calendars#Modern_calendar:_Solar_Hijri_(SH)
>     says "The present Iranian calendar was legally adopted on 31 March 1925"
>
>   * Ethiopia:
>     https://en.wikipedia.org/wiki/Ethiopian_calendar says it
>     "is the official state civil calendar of Ethiopia".
[...]
>
> The ISO C 23 § 7.29.3.5 and POSIX
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/strftime.html
> specifications specify an "alternative" choice feature. This code does
> *NOT* make use of this "alternative" API.
> It's better if the use of the specific calendar turns on the
> particular years, months names and numbers, days etc. all at once.
> Rationale:
>   - Because the "alternatives" approach that makes it too easy to produce
>     nonsensical output (as shown with %Y in the Thai locale, above).
>   - Because there is no documentation anywhere what "alternative" actually
>     means.
>   - Because in ISO C and POSIX the month number is specified to be in the
>     range 1..12, but some calendars (the Ethiopian calendar) have month
>     numbers 1..13.
>   - Because the month number to month name mapping may depend on the era
>     in some calendars (the Thai calendar).
>
> So, the code is careful not to mix Gregorian time elements (in 'struct tm')
> with non-Gregorian time elements (in 'struct calendar_date').
>
> Pádraig, you may add something like the following as a coreutils/NEWS entry:
>
>   'date' now outputs dates in the country's native calendar for the Iranian
>   locale (fa_IR) and for the Ethiopian locale (am_ET), and also does so more
>   consistently for the Thailand locale (th_TH.UTF-8).

Thank you for the interesting patch and explaining your reasonings.

I was going to write some tests for Coreutils, but had second thoughts
about this change after reading the POSIX documentation for 'date' [1]:

    The date string formatting capabilities are intended for use in
    Gregorian-style calendars, possibly with a different starting year
    (or years). The %x and %c conversion specifications, however, are
    intended for local representation; these may be based on a
    different, non-Gregorian calendar.

This is under APPLICATION USAGE, so not normative. But I think that most
people will assume that 'date' will return a Gregorian calendar date,
unless they explicitly use "%x" or "%c".

I think it would be good to support non-Gregorian calendars with those
format arguments, or a new option. But making it the default will just
require some users to remember to change their locale when posting the
output of 'date' in communication with foreigners (e.g. on a mailing
list).

As you mentioned, in Thailand the Gregorian calendar is used alongside
the Thai solar calendar (even if it is used less so in day-to-day life).
And the Ethiopian calendar has been a cause for confusion as the world
becomes more globalized [2]. I assume this was part of the reason Saudi
Arabia moved to the Gregorian Calendar in 2016 (although most of the
articles I found cited saving 11 days of yearly pay per government
employee) [3].

Collin

[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/date.html
[2] https://www.cnn.com/travel/ethiopian-unique-calendar-year
[3] 
https://www.economist.com/middle-east-and-africa/2016/12/15/saudi-arabia-adopts-the-gregorian-calendar

Reply via email to