Skip to content

Commit

Permalink
Merge 587b7d8 into 4d5c48e
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Jul 25, 2020
2 parents 4d5c48e + 587b7d8 commit 4ef012e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cftime/_cftime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ DATE_TYPES = {
}


@cython.embedsignature(True)
def to_calendar_specific_datetime(datetime, calendar, use_python_datetime):
"""
convert from one calendar-specific datetime instance to another.
If use_python_datetime=True, convert to python datetime (and ignore
calendar kwarg).
"""
if use_python_datetime:
date_type = real_datetime
else:
Expand Down Expand Up @@ -1113,6 +1119,17 @@ datetime object."""
else:
return NotImplemented

def toordinal(self):
"""
returns integer days since 1-1-1, like python's datetime toordinal.
"""
if self.calendar == '':
raise ValueError('calendar must be specified to compute ordinal')
else:
epoch = _IntJulianDayFromDate(1,1,1,self.calendar)
jd = _IntJulianDayFromDate(self.year,self.month,self.day,self.calendar)
return jd - epoch + 1

@cython.embedsignature(True)
cdef class DatetimeNoLeap(datetime):
"""
Expand Down

0 comments on commit 4ef012e

Please sign in to comment.