mirror of
https://github.com/kennethreitz/maya.git
synced 2026-06-05 23:00:18 +00:00
test_machine_parse
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user