Issue 42452 - hijri Date Number Format miscalculates
Summary: hijri Date Number Format miscalculates
Status: ACCEPTED
Alias: None
Product: Calc
Classification: Application
Component: formatting (show other issues)
Version: OOo 2.0
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-10 17:56 UTC by hurkanos
Modified: 2013-08-07 15:12 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
File shows miscalculation (8.40 KB, application/vnd.sun.xml.calc)
2005-02-10 17:58 UTC, hurkanos
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description hurkanos 2005-02-10 17:56:53 UTC
When converting DAte into hijri format, the formate miscalculates.

e.g. 16/7/622 schould return 1/1/1 hijri but it returns 2/1/1

This miscalculation continues until 2005.

I might provide the right calculating algorithm and a table that allowa for
comparision.

Kind regards
Shimshon Bar-Yehuda
Comment 1 hurkanos 2005-02-10 17:58:41 UTC
Created attachment 22424 [details]
File shows miscalculation
Comment 2 ooo 2005-02-11 12:28:10 UTC
Hi Shimshon,

There are two issues with the dates entered in the attached sample document:

1. Dates entered may not be correctly processed if they point before the
Gregorian calendar reformation, which is 1582-10-15, as there are several
different ways to calculate those, depending on what area you choose and when
the reformation happened in that specific area. It may be that your table/tool
chose a different approach than OOo.

2. AFAIK there are also different ways to calculate the Hijri calendar, I'm not
sure if there even is _the_ one and only algorithm to do it. For example, also
http://www.rabiah.com/convert/ mentions "There is a small probability of one day
error", and in fact for the newer dates has one date offset from your "external
calendar program", but gives identical results for older dates. That site, btw,
delivers identical results as http://www.islamicfinder.org/Hcal/index.php. On
the other hand, http://www.fourmilab.com/documents/calendar/ delivers identical
results to yours.

Could you please provide some pointers to what algorithm was used in your
comparison? Thanks.


Karl,
As you implemented the calendars I assign this issue to you. Note that it is
still unconfirmed and doesn't have a target set. Am I right in my previous
assumptions about different algorithms, or is there a real miscalculation in our
implementation? Is one of the other algorithms better than OOo's?

Thanks
Eike
Comment 3 ooo 2005-02-11 13:07:52 UTC
Found a good explanation about the 1 day error in Hijri date calculation, taken from
http://bennyhills.fortunecity.com/elfman/454/calindex.html#Error

        1. The Same Gregorian date may have actually 2-4 Hijri equivalent dates
according to the PLACE  & TIME of the day. The 1st of Ramadan in Jordan for
example could be the 30th of Shaban in some other parts of the world according
to the sighting of the moon, also 1st of Ramada at an instance in San Francisco
could be equivalent to the 2nd of Ramadan in China because of time zone
difference. To add on top that, the Isalmic & Hebrew days begin at sunset, so
the 1st of August before sunset & after sunset will correspond to 2 different
Islamic & Hebrew days.

         2. The conversion from & to the Hijri calendar is a pure mathematical
one, & for the reasons of conversion, I had to make the Islamic day start at
midnight. This is not true, but it makes conversion easier & wouldn't affect the
+/-1 day error that much.

        In reality,  the sighting of the moon is the basis of determining when
the month starts. Islamic Astronomers  have a fixed 30 year cycle which has the
2nd, 5th, 7th, 10th, 13th, 16th, 18th, 21st, 24th, 26th, and 29th years as leap
years of 355 days, this however is not taken into consideration by many Islamic
countries which consider the physical sighting of the moon as the only method of
determining the beginning of a lunar month. You have to remember also that  the
Islamic day starts at sunset & ends on the next sunset !

        But come now !!! Even with all of these errors, the total error is +/- 1
day, & even the most accurate of calculations will have the same error at the
end(look at the paragraph above) !! That makes my converter reliable, especially
if you knew that the method of determining the 1st day changes from one country
to another, bringing any converter to making predictions, not more !

        3. The Gregorian calendar was implemented in 1582 CE in ROME, so dates
before May, 1582 CE are calculated in reference to  the first day the Gregorian
calendar was implemented "Gregorian Proleptic Calendar." 

         4. Many countries adopted the Gregorian Calendar years after that date.
So you see, some of the errors are out of my hand & some can be corrected! (see
below). The transition between calendars gave the people the sense of losing
days, although when referring to the proper calendar, not a single day was
missed, but the problem was that no one referred to the proper calendar.
 
         5. One way to be 100% sure about the Hijri conversion is to know FOR
SURE the day of the week on which a certain Hijri date occurred, then you can
correct the Gregorian day result to that day of the week (That is if the results
didn't match ??!!), & remember to correct to the nearest day or then you will
FOR SURE be 7 days off your mark.
Comment 4 hurkanos 2005-02-12 17:42:55 UTC
1. I am well aware of the problems that arise from calculating Hijra-dates.

2. I do not think that there is any problem with dates before 1582-10-15, as far
as you use this date and no other as was done in most protastant countries.

3. Pointers: I. http://www.oriold.unizh.ch//static/hegira.html.
    II. Nachum Dershowitz and Edward M. Reingold,Calendrical Calculations,in:
Software-Practice and Experience, Vol 20(9)(1999), pp. 899-928.
http://emr.cs.iit.edu/home/reingold/calendar-book/papers/calendar.ps
(both yield the same values).

4. The start of the Hijra calendar should be 622-7-16, and no other date.

5. Orientalists are using the table by Wüstenfeld, Mahler:
"Vergleichungs-Tabellen" (Wiesbaden, 1961).

Paragraph 3 (both algorithms) and 4  yield the same values. This should be so,
since the table by Wüstenfeld was just counted.

If your program should calculate according to actual moon sighting, I can't add
anything.

As far as the Hebrew calander is concerned, I never experienced a problem and in
reality. The fact that the Muslim/Jewish day starts at sunset does not make up
for the 1-day difference.
Comment 5 karl.hong 2005-03-01 22:54:40 UTC
ICU 3.2 contains Arabic and Hebrew calendar, we will use them instead of
maintaining our own code when we upgrade icu for 2.0.1.
Comment 6 karl.hong 2005-08-24 00:05:22 UTC
Since we have not decided when we will upgrade icu to 3.2 or latest, I re-target
this issue to OOo Later. 
Comment 7 sparcmoz 2006-02-08 12:21:04 UTC
CasY reports on IRC the leap yers are wrong
" 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29"  i wanna only change 16 to 15
in file i18npool/source/calendar/calendar_hijri.cxx
Comment 8 ooo 2006-02-10 14:01:03 UTC
Hi Karl,

If this one leap year change causes the one-day-off calculation, I suggest to
include this minimal fix in OOo2.0.3 and not to wait for our ICU upgrade.
Somehow I'm not convinced though that this is related, even if the change would
be correct, or how would it explain the day off since the beginning of the calendar?

  Eike
Comment 9 sparcmoz 2006-02-12 02:43:53 UTC
According to the discussion here
http://www.phys.uu.nl/~vgent/islam/islamyear_en.htm 16 is "most commonly used"
while 15 is used by "Microsoft". The link provides a calculator that offers 8
different conversions for any given date. So I suppose my transmission of the
request from CasY could have said the reporter "requires" or "prefers" 15, not
that 16 "wrong". Hope that helps, I only wanted to pass on the from IRC.
Comment 10 ooo 2006-03-15 15:07:10 UTC
"Emre whose nick name is CasY" wrote me a personal mail with some
additional pointers. I asked him to add the information to this issue
instead, but so far he didn't, so this is it:


But you may create an algorithm with that books' perfect enlightenment:

In
http://www.hakikatkitabevi.com/download/download.htm#english

5-Endless Bliss Fifth Fascicle

This book's link is
http://www.hakikatkitabevi.com/download/english/05-EndlessBlis5.pdf

The book's Calculation knowledge's parts are:

* Endless Bliss Fifth Fascicle, Chapter 8: Conversion of the solar year
  into lunar year

* Endless Bliss Fifth Fascicle, Chapter 9: Conversion of the lunar year
  into the Christian year

* Endless Bliss Fifth Fascicle, Chapter 10: Finding the first day of
  Hegira year

* Endless Bliss Fifth Fascicle, Chapter 11: Finding the first day of any
  Arabic month

And also you can find a lot of information of this book and anothers from:
http://www.hizmetbooks.org/
Comment 11 karl.hong 2006-03-22 00:54:02 UTC
Hijri calendar is implemented by Bustamam who no longer works on this project.

The suggested fix, changing leap yers array, will not work, since the array is
not used in the program. 

Please provide patch for the issue.
Comment 12 comtelicon 2010-11-10 16:28:09 UTC
Created attachment 73191
Comment 13 Pedro Giffuni 2012-03-02 05:40:32 UTC
Comment on attachment 73191


Spam
Comment 14 Rob Weir 2013-07-30 02:37:31 UTC
Reset assignee on issues not touched by assignee in more than 1000 days.