ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:55295] [ruby-trunk - Bug #8485][Open] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
@ 2013-06-04  6:52 teleological (Riley Lynch)
  2013-06-04 22:25 ` [ruby-core:55307] [ruby-trunk - Bug #8485] " tadf (tadayoshi funaba)
  2013-06-28 21:08 ` [ruby-core:55691] [ruby-trunk - Bug #8485][Closed] " tadf (tadayoshi funaba)
  0 siblings, 2 replies; 3+ messages in thread
From: teleological (Riley Lynch) @ 2013-06-04  6:52 UTC (permalink / raw
  To: ruby-core


Issue #8485 has been reported by teleological (Riley Lynch).

----------------------------------------
Bug #8485: Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
https://bugs.ruby-lang.org/issues/8485

Author: teleological (Riley Lynch)
Status: Open
Priority: Normal
Assignee: 
Category: ext
Target version: 
ruby -v: ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.3.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=begin
In Ruby 1.9-2.0 date_core, the year and chronological Julian day of a Date are stored as offsets from an indexed period relative to 0j, -4712-01-01 in the Julian calendar. Each period consists of exactly 194,796 Julian years, i.e. 194,800 Gregorian years.

Since 0j is -4713-11-24 in the proleptic Gregorian calendar, Gregorian calendar years do not align with these periods. A problem occurs when decode_years() uses the Gregorian calendar year of a Date in the the first 38 days of a period to assign the period index ("nth"). The calculation of nth ((y + 4712) / CM_PERIOD_GCY) is incorrect from November 24 until and including December 31. As a result of this error, an instance with period nth-1 is not equivalent to instances that represent the same Julian day, but which are constructed with an accurate period. These tests, which pass under Ruby 1.8, demonstrate the defect:

  assert_equal(0, (Date.jd(0) <=> Date.civil(-4713, 11, 24, Date::GREGORIAN)))
  assert_equal(0, (Date.jd(213447717) <=> Date.civil(579687, 11, 24)))
  assert_equal(0, (Date.jd(-213447717) <=> Date.civil(-589113, 11, 24, Date::GREGORIAN)))

Attached is a patch against trunk which corrects this issue for methods which use decode_year() to assign the period index, including Date.civil, Date.ordinal and Date.commercial.
=end



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:55307] [ruby-trunk - Bug #8485] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
  2013-06-04  6:52 [ruby-core:55295] [ruby-trunk - Bug #8485][Open] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD teleological (Riley Lynch)
@ 2013-06-04 22:25 ` tadf (tadayoshi funaba)
  2013-06-28 21:08 ` [ruby-core:55691] [ruby-trunk - Bug #8485][Closed] " tadf (tadayoshi funaba)
  1 sibling, 0 replies; 3+ messages in thread
From: tadf (tadayoshi funaba) @ 2013-06-04 22:25 UTC (permalink / raw
  To: ruby-core


Issue #8485 has been updated by tadf (tadayoshi funaba).

Assignee set to tadf (tadayoshi funaba)

different alignments are intentional.
nearly all parts don't require normalized nth and jd.
however, <=> is an exception.
thanks.
----------------------------------------
Bug #8485: Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
https://bugs.ruby-lang.org/issues/8485#change-39703

Author: teleological (Riley Lynch)
Status: Open
Priority: Normal
Assignee: tadf (tadayoshi funaba)
Category: ext
Target version: 
ruby -v: ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.3.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=begin
In Ruby 1.9-2.0 date_core, the year and chronological Julian day of a Date are stored as offsets from an indexed period relative to 0j, -4712-01-01 in the Julian calendar. Each period consists of exactly 194,796 Julian years, i.e. 194,800 Gregorian years.

Since 0j is -4713-11-24 in the proleptic Gregorian calendar, Gregorian calendar years do not align with these periods. A problem occurs when decode_years() uses the Gregorian calendar year of a Date in the the first 38 days of a period to assign the period index ("nth"). The calculation of nth ((y + 4712) / CM_PERIOD_GCY) is incorrect from November 24 until and including December 31. As a result of this error, an instance with period nth-1 is not equivalent to instances that represent the same Julian day, but which are constructed with an accurate period. These tests, which pass under Ruby 1.8, demonstrate the defect:

  assert_equal(0, (Date.jd(0) <=> Date.civil(-4713, 11, 24, Date::GREGORIAN)))
  assert_equal(0, (Date.jd(213447717) <=> Date.civil(579687, 11, 24)))
  assert_equal(0, (Date.jd(-213447717) <=> Date.civil(-589113, 11, 24, Date::GREGORIAN)))

Attached is a patch against trunk which corrects this issue for methods which use decode_year() to assign the period index, including Date.civil, Date.ordinal and Date.commercial.
=end



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:55691] [ruby-trunk - Bug #8485][Closed] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
  2013-06-04  6:52 [ruby-core:55295] [ruby-trunk - Bug #8485][Open] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD teleological (Riley Lynch)
  2013-06-04 22:25 ` [ruby-core:55307] [ruby-trunk - Bug #8485] " tadf (tadayoshi funaba)
@ 2013-06-28 21:08 ` tadf (tadayoshi funaba)
  1 sibling, 0 replies; 3+ messages in thread
From: tadf (tadayoshi funaba) @ 2013-06-28 21:08 UTC (permalink / raw
  To: ruby-core


Issue #8485 has been updated by tadf (tadayoshi funaba).

Status changed from Open to Closed


----------------------------------------
Bug #8485: Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD
https://bugs.ruby-lang.org/issues/8485#change-40190

Author: teleological (Riley Lynch)
Status: Closed
Priority: Normal
Assignee: tadf (tadayoshi funaba)
Category: ext
Target version: 
ruby -v: ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.3.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=begin
In Ruby 1.9-2.0 date_core, the year and chronological Julian day of a Date are stored as offsets from an indexed period relative to 0j, -4712-01-01 in the Julian calendar. Each period consists of exactly 194,796 Julian years, i.e. 194,800 Gregorian years.

Since 0j is -4713-11-24 in the proleptic Gregorian calendar, Gregorian calendar years do not align with these periods. A problem occurs when decode_years() uses the Gregorian calendar year of a Date in the the first 38 days of a period to assign the period index ("nth"). The calculation of nth ((y + 4712) / CM_PERIOD_GCY) is incorrect from November 24 until and including December 31. As a result of this error, an instance with period nth-1 is not equivalent to instances that represent the same Julian day, but which are constructed with an accurate period. These tests, which pass under Ruby 1.8, demonstrate the defect:

  assert_equal(0, (Date.jd(0) <=> Date.civil(-4713, 11, 24, Date::GREGORIAN)))
  assert_equal(0, (Date.jd(213447717) <=> Date.civil(579687, 11, 24)))
  assert_equal(0, (Date.jd(-213447717) <=> Date.civil(-589113, 11, 24, Date::GREGORIAN)))

Attached is a patch against trunk which corrects this issue for methods which use decode_year() to assign the period index, including Date.civil, Date.ordinal and Date.commercial.
=end



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-28 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04  6:52 [ruby-core:55295] [ruby-trunk - Bug #8485][Open] Incorrect period index for Gregorian Dates at beginning of each CM_PERIOD teleological (Riley Lynch)
2013-06-04 22:25 ` [ruby-core:55307] [ruby-trunk - Bug #8485] " tadf (tadayoshi funaba)
2013-06-28 21:08 ` [ruby-core:55691] [ruby-trunk - Bug #8485][Closed] " tadf (tadayoshi funaba)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).