dhlab-basel / JDNConvertibleCalendar

Different calendars can be freely converted using Julian Day Number
GNU Affero General Public License v3.0
4 stars 3 forks source link

fix(Gregorian to JDC): handle Gregorian dates prior to 15.10.1582 correctly #30

Closed tobiasschweizer closed 3 years ago

tobiasschweizer commented 3 years ago

This PR adds assertions to detect a bug in https://github.com/dhlab-basel/JDNConvertibleCalendar/blob/51331f72fb9ed53dbba75bafab20580509b5fe27/src/JDNCalendarConversion.ts#L50

tobiasschweizer commented 3 years ago

@gautschr I am getting three failing tests:

1) Conversion of a Gregorian calendar date to JDC convert the Gregorian Calendar date 01-02(-1899) to JDC:

  AssertionError [ERR_ASSERTION]: JDC is wrong: received JDN is 1027496.5 instead of 1027495.5
  + expected - actual

  -1027496.5
  +1027495.5

  at checkJDC (dist/test/conversions.js:60:12)
  at Context.<anonymous> (dist/test/conversions.js:99:9)
  at processImmediate (internal/timers.js:439:21)
  at process.topLevelDomainCallback (domain.js:131:23)

2) Conversion of a Gregorian calendar date to JDC convert the Gregorian Calendar date 28-02(-99) to JDC:

  AssertionError [ERR_ASSERTION]: JDC is wrong: received JDN is 1684959.5 instead of 1684958.5
  + expected - actual

  -1684959.5
  +1684958.5

  at checkJDC (dist/test/conversions.js:60:12)
  at Context.<anonymous> (dist/test/conversions.js:109:9)
  at processImmediate (internal/timers.js:439:21)
  at process.topLevelDomainCallback (domain.js:131:23)

3) Get the number of days for a given month create a Gregorian date and get the number of days for a given BCE Gregorian date's month :

  AssertionError [ERR_ASSERTION]: wrong number of days
  + expected - actual

  -27
  +28

  at Context.<anonymous> (dist/test/conversions.js:1048:16)
  at processImmediate (internal/timers.js:439:21)
  at process.topLevelDomainCallback (domain.js:131:23)