Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #543 (closed defect: fixed)

Opened 17 years ago

Last modified 17 years ago

Incorrect hebrew date calculations

Reported by: snoyberg Assigned to: kris
Priority: normal Milestone: 0.99.1 RC4
Component: Tango Version: trunk
Keywords: calendar hebrew Cc:

Description

This actually turned out to be a very simple bug. In the function getYearType, non-leap year values were being returned one too small. Since the MonthDays? array essentially starts at an index of 1, you need to return values between 1-6.

Attachments

Hebrew.d.diff (0.7 kB) - added by snoyberg on 07/16/07 06:27:57.
Unified diff
Hebrew.d.diff.v2 (1.5 kB) - added by snoyberg on 08/17/07 17:28:20.
Correction of array offset and repositioning 0-length month in non-leap years

Change History

07/16/07 06:27:57 changed by snoyberg

  • attachment Hebrew.d.diff added.

Unified diff

08/16/07 22:09:59 changed by kris

  • status changed from new to assigned.

I don't have the same code as you, for some reason. That is, case 353 already returns 0

Hrm

08/16/07 22:28:09 changed by snoyberg

That's my point. The array "MonthDays?" is really based at 1, so 353 should return 1. For some reason, the leap years are fine (ie, 4-6), but the non-leap years return 0-2 instead of 1-3.

Here's a second bug, also for non-leap years. Lines 29-31 of the file define the length of each month. When there's a leap year, an extra month is added in the middle of the year (it takes spot number seven). So for non-leap years, month seven should be length zero. In other words, change:

	    [ 0, 30, 29, 29, 29, 30, 29, 30, 29, 30, 29, 30, 29, 0 ],   // 1
	    [ 0, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 0 ],   // 2
	    [ 0, 30, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 0 ],   // 3

to

	    [ 0, 30, 29, 29, 29, 30, 29, 0, 30, 29, 30, 29, 30, 29 ],   // 1
	    [ 0, 30, 29, 30, 29, 30, 29, 0, 30, 29, 30, 29, 30, 29 ],   // 2
	    [ 0, 30, 30, 30, 29, 30, 29, 0, 30, 29, 30, 29, 30, 29 ],   // 3

Note: I'm already using this changes in production code on a website I maintain at http://www.kehilla.org/. For those interested, I run that site on a web framework I've written against Tango which I (endearingly) call Snoyweb.

08/17/07 15:30:19 changed by kris

  • milestone set to 0.99.1 RC4.

What I meant was that the diff file appeared to be inverted :)

Could you please attach an updated patch file, with the array adjustments also? I'll get those changes into Tango

thx

08/17/07 17:28:20 changed by snoyberg

  • attachment Hebrew.d.diff.v2 added.

Correction of array offset and repositioning 0-length month in non-leap years

08/28/07 06:27:23 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [2519]) closes #543 :: Incorrect hebrew date calculations

Thanks to snoyberg