[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Hijri calendar support in glibc
- To: developer at arabeyes dot org
- Subject: Hijri calendar support in glibc
- From: أحمد المحمودي <aelmahmoudy at users dot sourceforge dot net>
- Date: Thu, 14 Feb 2008 21:20:06 +0200
- User-agent: Mutt/1.5.17+20080114 (2008-01-14)
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
--
أحمد المحمودي (Ahmed El-Mahmoudy)
Digital design engineer
GPG KeyID: 0x9DCA0B27 (@ subkeys.pgp.net)
GPG Fingerprint: 087D 3767 8CAC 65B1 8F6C 156E D325 C3C8 9DCA 0B27