I want to define a custom locale with my own calendar settings. In this locale, we set a specified year as the first year. For example, if I define a en_UNIX.UTF-8, I'd like to set AD 1970 as year 1, and AD 1970 as year 2.
Is there any way to do this in Linux/BSD? I looked into system's locale files and found they only defined the first day of week, currency and so on except the first year of calendar…
Best Answer
Use of the gregorian calendar is hard-coded in glibc: https://github.com/rbdixon/glibc/blob/master/time/offtime.c#L58
So anything that uses the C library ("system") routines -
gmtime_r
,localtime_r
and so on - to convert between seconds-since-the-epoch and broken-down-date format, will stick to the "standard" calendar (365 days in a year, Gregorian leap-year formula, 7 days per week...).For code you write yourself, you could use the ICU Project's libraries and provide your own non-Gergorian calendar specification in the Unicode Common Locale Data Repository XML format.
I'm pretty sure you don't want to do that.