Hijri calendar implementation in glibc

Registered by أحمد المحمودي (Ahmed El-Mahmoudy) on 2009-05-08

A suggestion on implementing Hijri (and possibly any other non-gregorian based calendar) in glibc

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

as-salamu alaykom,

  I have been doing some research about the possibility of adding hijri
  calendar directly into glibc.
  I found that glibc does support other calendars, such as Buddhist Era
  (using in Thailand, and Laos I think) and the Japanese Emperors'
  reigns.

  That is done by adding definitions for era, era_d_t_fmt, era_d_fmt,
  era_t_fmt, and alt_digits in the locale [1].

  Those definitions modify the behaviour of some time functions (such as
  strftime) when E and O modifiers are used [2].

  The format of 'era' consists of semicolon-separated strings. Each
  string shall be an era description segment with the format:

  direction:offset:start_date:end_date:era_name:era_format

  The descriptions for each field are in [1].

  Now the problem is that supported calendars are those which are based
  on Gregorian calendar. In [3] it says:

  The E modifier supports alternative date formats, such as the Japanese
  Emperor's Era, as long as these are based on the Gregorian calendar
  system. Extending the E modifiers to other date elements may provide
  an implementation-defined extension capable of supporting other
  calendar systems, especially in combination with the O modifier.

  So, I was thinking, that this 'era' can be used for Hijri as follows:

  1. For countries that formally use Hijri system, we can add an 'era'
  definition in their respective locale files. The era field that
  matters now is 'era_name'. It can be something like "A.H." or even
  "ه".

  2. In glibc C code: a conversion function from Gregorian to Hijri can
  be added, I was thinking of using the conversion functions that
  implement the Um-Ul-Qura algorithm since, as far as I know, this is
  the algorithm that is formally used in Arabia.

  3. Somewhere in glibc's time/strftime_l.c & time/strptime_l.c [4], the
  code should check if era_name is "A.H" or "ه", if that is true, it
  will call for the conversion function to get the appropriate Hijri
  date.

  I hope to get your comments on this suggestion.

  [1] http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_03_05
  [2] http://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html#Formatting-Calendar-Time
  [3] http://www.opengroup.org/onlinepubs/009695399/utilities/date.html
  [4] http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/time/strftime_l.c?cvsroot=glibc
    & http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/time/strptime_l.c?cvsroot=glibc

  Here's a log of a chat I had last year on Freenode's #glibc channel regarding this topic:
--- Log opened Fri Jan 25 14:53:24 2008
15:06 >ryanarn< AnAnt: It's worth a shot. If you can find a specification talking about an interface you should probably shoot an email to <email address hidden> and propose it and see what the response is.
15:07 <AnAnt> ryanarn: what do you mean by "would-be presented to user" ? I know that there is some standard of calculating hijri date , called Umm-Ul-Qura timing
15:07 >ryanarn< AnAnt interfaces to change the display format, interfaces to change the date representation etc.
15:08 <AnAnt> ryanarn: ok, I'll research that, thanks for the info.
15:08 <ryanarn> y/w
15:11 >ryanarn< AnAnt something like ISO 8601 http://en.wikipedia.org/wiki/ISO_8601 but with Hijri in mind perhaps.
15:13 -- steelman [<email address hidden>] has joined #glibc
15:14 <AnAnt> ryanarn: ah, should it be some ISO too ?
15:14 >ryanarn< AnAnt perhaps but I wouldn't be surprised if there wasn't.
15:19 <ryanarn> you need to do your homework, research the standards and go to the mailing list with a well researched plan.
15:20 <AnAnt> what do you mean by a plan ?
15:20 <AnAnt> I mean, what should be provided in that plan ?
15:21 >ryanarn< AnAnt on what interfaces in glibc may need extension, what internals will need extension, the repercussions to user applications, etc.
15:27 <AnAnt> ryanarn: can I provide links from microsoft ? googling gave me results from MSDN
15:28 >ryanarn< AnAnt: that's NOT a good idea.
15:29 <ryanarn> Microsoft is not the pinnacle of standards compliance so you can't hold their implementations up as a baseline.
--- Log closed Fri Jan 25 15:32:35 2008

===== Rajab 2, 1430 (Jun 25 2009)
dholbach has directed my attention to a feature request for GLib (probably there will be something in GLib 3.0):
http://bugzilla.gnome.org/show_bug.cgi?id=344005

From there, there is this probably some useful URLs:

Era entries for Islamic calendar:
http://unicode.org/cldr/repository/common/supplemental/supplementalData.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup (this page is long, just search for the word "islam" there)

Unicode Locale Data Markup Language: http://www.unicode.org/reports/tr35

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.