diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..03c4dc7 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[packages] +humanize = "*" +pytz = "*" +dateparser = "*" +iso8601 = "*" +python-dateutil = "*" +"ruamel.yaml" = "*" +tzlocal = "*" + +[dev-packages] +pytest = "*" diff --git a/maya.py b/maya.py index e7323b0..7a0c7df 100644 --- a/maya.py +++ b/maya.py @@ -139,6 +139,11 @@ class MayaDT(object): """Returns MayaDT instance from rfc2822 string.""" return parse(string) + @staticmethod + def from_rfc3339(string): + """Returns MayaDT instance from rfc3339 string.""" + return parse(string) + # Exporters # --------- @@ -175,6 +180,10 @@ class MayaDT(object): """Returns an RFC 2822 representation of the MayaDT.""" return email.utils.formatdate(self.epoch, usegmt=True) + def rfc3339(self): + """Returns an RFC 3339 representation of the MayaDT.""" + return self.datetime().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-4]+"Z" + # Properties # ---------- diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9878b9d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ --e . -dateparser==0.5.0 -humanize==0.5.1 -iso8601==0.1.11 -jdatetime==1.8.1 -py==1.4.32 -pytest==3.0.5 -python-dateutil==2.6.0 -pytz==2016.10 -regex==2016.11.21 -#ruamel.ordereddict is only needed for python 2 -#ruamel.ordereddict==0.4.9 -ruamel.yaml==0.13.4 -six==1.10.0 -typing==3.5.2.2 -tzlocal==1.3 -umalqurra==0.2 diff --git a/setup.py b/setup.py index 38389c1..0b1d083 100755 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ required = [ setup( name='maya', - version='0.1.6', + version='0.1.7', description='Datetimes for Humans.', long_description=long_description, author='Kenneth Reitz', diff --git a/test_maya.py b/test_maya.py index 7f63465..bdcf470 100644 --- a/test_maya.py +++ b/test_maya.py @@ -115,6 +115,12 @@ def test_datetime_to_timezone(): dt = maya.when('2016-01-01').datetime(to_timezone='US/Eastern') assert dt.tzinfo.zone == 'US/Eastern' +def test_rfc3339(): + mdt = maya.when('2016-01-01') + out = mdt.rfc3339() + mdt2 = maya.MayaDT.from_rfc3339(out) + assert mdt.epoch == mdt2.epoch + def test_comparison_operations(): now = maya.now()