test_machine_parse

This commit is contained in:
2016-12-18 02:01:17 -05:00
parent 2382c6f4eb
commit 764cc49c53
2 changed files with 12 additions and 0 deletions
+5
View File
@@ -62,6 +62,11 @@ class MayaDT(object):
@staticmethod
def __dt_to_epoch(dt):
"""Converts a datetime into an epoch."""
# Assume UTC if no datetime is provided.
if dt.tzinfo is None:
dt = dt.replace(tzinfo=pytz.utc)
epoch_start = Datetime(*EPOCH_START, tzinfo=pytz.timezone('UTC'))
return (dt - epoch_start).total_seconds()
+7
View File
@@ -19,6 +19,13 @@ def test_human_when():
assert r2.day - r1.day == 1
def test_machine_parse():
r1 = maya.parse('August 14, 2015')
assert r1.day == 14
r2 = maya.parse('August 15, 2015')
assert r2.day == 15
def test_dt_tz_translation():
d1 = maya.now().datetime()