Merge branch 'master' of https://github.com/kennethreitz/maya into decorator_remove

This commit is contained in:
Moin
2016-12-29 14:38:47 +05:30
5 changed files with 48 additions and 36 deletions
+7 -3
View File
@@ -1,8 +1,12 @@
language: python
python:
- "2.7"
# - "3.5" # looks like ruamel.ordereddict doesn't build for python3
- "3.3"
- "3.4"
- "3.5"
- "3.6"
# command to install dependencies
install: "pip install -r requirements.txt"
install: pip install -r requirements.txt
# command to run tests
script: make
script: make
+5 -1
View File
@@ -33,6 +33,9 @@ class MayaDT(object):
def __repr__(self):
return '<MayaDT epoch={}>'.format(self._epoch)
def __str__(self):
return self.rfc2822()
def __format__(self, *args, **kwargs):
"""Return's the datetime's format"""
return format(self.datetime(), *args, **kwargs)
@@ -216,7 +219,8 @@ class MayaDT(object):
def slang_date(self):
""""Returns human slang representation of date."""
return humanize.naturaldate(self.datetime())
dt = self.datetime(naive=True, to_timezone=self.local_timezone)
return humanize.naturaldate(dt)
def slang_time(self):
""""Returns human slang representation of time."""
+3 -2
View File
@@ -1,4 +1,4 @@
-e .
-e .
dateparser==0.5.0
humanize==0.5.1
iso8601==0.1.11
@@ -8,7 +8,8 @@ pytest==3.0.5
python-dateutil==2.6.0
pytz==2016.10
regex==2016.11.21
ruamel.ordereddict==0.4.9
#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
+4 -3
View File
@@ -16,8 +16,9 @@ except ImportError:
here = os.path.abspath(dirname(__file__))
def read(*parts):
return codecs.open(os.path.join(here, *parts), 'r').read()
with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = '\n' + f.read()
if sys.argv[-1] == "publish":
os.system("python setup.py sdist bdist_wheel upload")
@@ -37,7 +38,7 @@ setup(
name='maya',
version='0.1.4',
description='Datetimes for Humans.',
long_description= '\n' + read('README.rst'),
long_description=long_description,
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
url='https://github.com/kennethreitz/maya',
+29 -27
View File
@@ -36,7 +36,7 @@ def test_machine_parse():
def test_dt_tz_translation():
d1 = maya.now().datetime()
d2 = maya.now().datetime(to_timezone='US/Eastern')
assert d1.hour - d2.hour == 5
assert (d1.hour - d2.hour) % 24 == 5
def test_dt_tz_naive():
@@ -45,18 +45,34 @@ def test_dt_tz_naive():
d2 = maya.now().datetime(to_timezone='US/Eastern', naive=True)
assert d2.tzinfo is None
assert d1.hour - d2.hour == 5
assert (d1.hour - d2.hour) % 24 == 5
def test_random_date():
d = maya.when('11-17-11 08:09:10')
assert d.year == 2011
assert d.month == 11
assert d.day == 17
assert d.hour == 8
assert d.minute == 9
assert d.second == 10
assert d.microsecond == 0
# Test properties for maya.when()
d1 = maya.when('11-17-11 08:09:10')
assert d1.year == 2011
assert d1.month == 11
assert d1.day == 17
assert d1.week == 46
assert d1.weekday == 4
assert d1.hour == 8
assert d1.minute == 9
assert d1.second == 10
assert d1.microsecond == 0
# Test properties for maya.parse()
d2 = maya.parse('February 29, 1992 13:12:34')
assert d2.year == 1992
assert d2.month == 2
assert d2.day == 29
assert d2.week == 9
assert d2.weekday == 6
assert d2.hour == 13
assert d2.minute == 12
assert d2.second == 34
assert d2.microsecond == 0
def test_print_date(capsys):
@@ -64,7 +80,9 @@ def test_print_date(capsys):
print(d)
out, err = capsys.readouterr()
assert out == '<MayaDT epoch=1321488000.0>\n'
assert out == 'Thu, 17 Nov 2011 00:00:00 GMT\n'
assert repr(d) == '<MayaDT epoch=1321488000.0>'
def test_invalid_date():
@@ -120,19 +138,3 @@ def test_comparison_operations():
assert (now >= now_copy) is True
assert (now >= tomorrow) is False
def test_weekday():
dt = maya.parse('February 21, 1994')
assert dt.weekday == 1 # was a Monday
dt = maya.parse('February 29, 1992')
assert dt.weekday == 6 # was a Saturday
def test_week():
dt = maya.parse('February 21, 1994')
assert dt.week == 8
dt = maya.parse('May 29, 1992')
assert dt.week == 22