Skip to content

Commit 15aab33

Browse files
author
Jeff Whitaker
authored
Merge pull request #127 from Unidata/issue126
fix for issue #126
2 parents 08d1caa + 68d7bce commit 15aab33

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

cftime/_cftime.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cdef int[13] _spm_366day = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 33
4343
_rop_lookup = {Py_LT: '__gt__', Py_LE: '__ge__', Py_EQ: '__eq__',
4444
Py_GT: '__lt__', Py_GE: '__le__', Py_NE: '__ne__'}
4545

46-
__version__ = '1.0.4'
46+
__version__ = '1.0.4.1'
4747

4848
# Adapted from http://delete.me.uk/2005/03/iso8601.html
4949
# Note: This regex ensures that all ISO8601 timezone formats are accepted - but, due to legacy support for other timestrings, not all incorrect formats can be rejected.
@@ -183,7 +183,7 @@ def date2num(dates,units,calendar='standard'):
183183
ismasked = True
184184
times = []
185185
for date in dates.flat:
186-
if getattr(date, 'tzinfo') is not None:
186+
if getattr(date, 'tzinfo',None) is not None:
187187
date = date.replace(tzinfo=None) - date.utcoffset()
188188

189189
if ismasked and not date:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ def description():
119119
'Programming Language :: Python :: 3.6',
120120
'Programming Language :: Python :: 3.7',
121121
'Topic :: Scientific/Engineering',
122-
'License :: OSI Approved'])
122+
'License :: OSI Approved :: GNU General Public License V3 (GPLV3)'])

test/test_cftime.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,10 @@ def test_tz_naive(self):
711711
assert(cftime.date2num(cftime.datetime(1, 12, 1, 0, 0, 0, 0, -1, 1), units='days since 01-01-01',calendar='noleap') == 334.0)
712712
assert(cftime.date2num(cftime.num2date(1.0,units='days since 01-01-01',calendar='noleap'),units='days since 01-01-01',calendar='noleap') == 1.0)
713713
assert(cftime.date2num(cftime.DatetimeNoLeap(1980, 1, 1, 0, 0, 0, 0, 6, 1),'days since 1970-01-01','noleap') == 3650.0)
714-
714+
# issue #126
715+
d = cftime.DatetimeProlepticGregorian(1, 1, 1)
716+
assert(cftime.date2num(d, 'days since 0001-01-01',\
717+
'proleptic_gregorian') == 0.0)
715718

716719
class TestDate2index(unittest.TestCase):
717720

0 commit comments

Comments
 (0)