Skip to content

roundtrip for proleptic_gregorian calendar wrong for reference dates before Julian/Gregorian transition #189

Closed

Description

@jswhit
import cftime as cf
from cftime import DatetimeProlepticGregorian as datetime
dt1 = datetime(2020, 4, 24, 16, 15, 10)
print(dt1)
units='days since -4713-01-01 12:00'
cal='proleptic_gregorian'
print(cf.num2date(cf.date2num(dt1, units, cal), units, cal))

2020-04-24 16:15:10
2020-03-19 16:15:10

For this example, it's off by 38 days.

Correct result is obtained if reference date year changed to 1583.

Activity

  1. jswhit commented on Jul 17, 2020

    @jswhit
    CollaboratorAuthor

    Actually, it works for reference date years back to -100. Suspect it has something to do with the calculation of leap years for negative years.

    It's a bug in _is_leap - fix is included in PR #188

  2. jswhit commented on Jul 18, 2020

    @jswhit
    CollaboratorAuthor

    closed by PR #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions