Skip to content

Commit

Permalink
Map gregorian calendar to standard calendar (not the other way around)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbarring committed Oct 30, 2021
1 parent a69d7c8 commit 1138ed6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cf_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
#: Where calendars have multiple names, we map the alias to the
#: definitive form.
CALENDAR_ALIASES = {
CALENDAR_STANDARD: CALENDAR_GREGORIAN,
CALENDAR_GREGORIAN: CALENDAR_STANDARD,
CALENDAR_NO_LEAP: CALENDAR_365_DAY,
CALENDAR_ALL_LEAP: CALENDAR_366_DAY,
}
Expand Down Expand Up @@ -830,7 +830,7 @@ def __init__(self, unit, calendar=None):
raise value_error from None
if _OP_SINCE in unit.lower():
if calendar is None:
calendar_ = CALENDAR_GREGORIAN
calendar_ = CALENDAR_STANDARD
elif isinstance(calendar, (str,)):
calendar_ = calendar.lower()
if calendar_ in CALENDAR_ALIASES:
Expand Down Expand Up @@ -1815,7 +1815,7 @@ def convert(self, value, other, ctype=FLOAT64, inplace=False):
# gregorian calendar as it handles these and udunits does not.
if (
self.is_time_reference()
and self.calendar != CALENDAR_GREGORIAN
and self.calendar != CALENDAR_STANDARD
):
result_datetimes = cftime.num2date(
result, self.cftime_unit, self.calendar
Expand Down

0 comments on commit 1138ed6

Please sign in to comment.