Page MenuHomePhabricator

Adding other calendars to user-preferences-date
Open, LowPublicFeature

Description

Author: beseg7

Description:
Here is a patch file for adding some official calendars, to use in
user-perefences-date (WatchList etc.) or even in system-date (default for users,
<nowiki>~~~~, ~~~~~</nowiki>).

The calendars that are patched here are:

  • ewish (Hebrew, Israeli) calendar (languages msgs updated: he, en)
  • slamic (Muslim, Hijri, Arabic) calendar (languages msgs updated: ar, en)
  • ersian (Iranian, Jalāli) calendar (languages msgs updated: fa, ku, en)
  • aka (Indian national) calendar (languages msgs updated: hi, en)

A new file was created – Calendars.php. It contains converesions from the
Gregorian date to the 4 dates above.

The file Language.php updated by:

  • requiring Calendars.php
  • adding some arrays & 'get'-functions for month names
  • changing "sprintfDate" function, by:
    • adding option to use all those calendars (see in the documentation)
    • adding option to use Hebrew-Gematria for Jewish dates
  • adding "hebrewNumeral" function for Hebrew-Gematria

The file Defines.php updated by adding 4 new symbols for those calendars.

I checked all the calendars, and they seem to work correctly.

Due to my ignorance in other languages, I didn't know how to write genitive
months in Arabic, Persian, Kurdish & Hindu, so I wrote them as non-genitive
months. Please, someone check it.


Version: unspecified
Severity: enhancement

Details

Reference
bz8385

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:32 PM
bzimport set Reference to bz8385.
bzimport added a subscriber: Unknown Object (MLST).

beseg7 wrote:

the patch file for all described things

Attached:

jeluf wrote:

Why are you converting manually, instead of using PHP's calendar functions?

http://de.php.net/manual/en/ref.calendar.php

ayg wrote:

Since calendar functions are an optional part of the install, they may as well
be used only if they exist, with the patch's functions as fallbacks.

beseg7 wrote:

At first I wrote just the Jewish calendar, and I used the PHP calendar
functions. [[user:rotemliss|]] adviced me to do it without this because it's
optional, as Simetrical said.
Also, as you can see, they don't support Islamic calendar, Persian calendar and
Saka calendar.

rotemliss wrote:

Iranian calendar was added in r27184, and Hebrew calendar in r27461.

To my knowledge (I try to investigate more about it) Islamic calendar is not this easy to convert; it is a lunar calendar, and still the beginning of some months (in particular Ramadan and Shawwal) is defined when the new moon is sighted. What offered in the patch by Shoham may be the best prediction method, but it is still not 100% accurate.

sumanah wrote:

Yaakov Shoham, thank you for your patch. Sorry for the wait in reviewing it!

Could you take a look at the most current version of MediaWiki (in Subversion trunk) and see whether your patch still cleanly applies?

You might also want to float this idea past the translatewiki.net people, to see if they have any ideas on how to implement this best.

rotemliss wrote:

Iranian, Hebrew and Hijri calendars were all added. It seems that only the Indian calendar is still missing. Anyway, the patch should be changed to match the current structure of other calendars, in languages/Language.php.

Iranian calender (Jalaly) has bug in converting (under year 1600)

{{#time:xij xiF xiY|30 January 2010}}==>۱۰ بهمن ۱۳۸۸ (ok)

{{#time:xij xiF xiY|30 January 1600}}==>-۴۹ فروردین ۹۴۲ (not ok)

{{#time:xij xiF xiY|30 January 1599}}==>-۴۱۴ فروردین ۹۴۲ (not ok)

{{#time:xij xiF xiY|30 January 1598}}==>-۷۷۹ فروردین ۹۴۲ (not ok)

{{#time:xij xiF xiY|30 January 1597}}==>-۱۱۴۴ فروردین ۹۴۲ (not ok)

nzmoihue wrote:

@reza1615: interesting, 1600 is hard coded somehow on the algorithm https://github.com/wikimedia/mediawiki-core/blob/1bea3da95b2a5ee1f88ba617c559d111c2fc9a83/languages/Language.php#L1434 I think we should think about a replacement for it.

I strongly discourage you from removing the hard-coded 1600 out of the algorithm, without consulting Rouzbeh Pournader (the original developer of that date conversion algorithm).

Please also notice that before a certain date, any conversions between Jalali and Gregorian calendar is inaccurate, for several reasons. For instance, before year 1304 Jalali, the calendar system was not officially used in any country, and there were 32 day months in Iran.

In short: date conversion is not a purely mathematical problem.

nzmoihue wrote:

I can not even if I want! :) I meant replacing with another algorithm. I am glad that you want solve it!

Qgil renamed this task from Adding other calendars to Adding other calendars to user-preferences-date.Sep 8 2015, 6:04 PM
Qgil set Security to None.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM