Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kennethreitz/maya
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethreitz committed Dec 18, 2016
2 parents a88b8e1 + 5e48539 commit be29d01
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
13 changes: 9 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Behold, datetimes for humans!
>>> tomorrow.iso8601()
'2016-12-16T15:11:30.263350Z'
>>> tomorrrow.rfc2822()
>>> tomorrow.rfc2822()
'Fri, 16 Dec 2016 20:11:30 -0000'
>>> tomorrow.datetime()
Expand Down Expand Up @@ -60,10 +60,10 @@ Behold, datetimes for humans!
- All timezone algebra will behave identically on all machines, regardless of system locale.
- Complete symmetric import and export of both ISO 8601 and RFC 2822 datetime stamps.
- Fantastic parsing of both dates written for/by humans and machines (``maya.when()`` vs ``maya.parse()``).
- Support for human slang, both import and export (e.g. `an hour ago`).
- Datetimes can very easily be generated, with our without tzinfo attached.
- Support for human slang, both import and export (e.g. `an hour ago`).
- Datetimes can very easily be generated, with or without tzinfo attached.
- This library is based around epoch time, but dates before Jan 1 1970 are indeed supported, via negative integers.
- Maya never panics, and always carrys a towel.
- Maya never panics, and always carries a towel.

☤ Installing Maya
-----------------
Expand All @@ -73,3 +73,8 @@ Installation is easy, with pip::
$ pip install maya

✨🍰✨

☤ Like it?
----------

`Say Thanks <https://saythanks.io/to/kennethreitz>`_!
4 changes: 2 additions & 2 deletions maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __repr__(self):

def __format__(self, *args, **kwargs):
"""Return's the datetime's format"""
return self.datetime(*args, **kwargs)
return format(self.datetime(*args, **kwargs))

# Timezone Crap
# -------------
Expand Down Expand Up @@ -205,4 +205,4 @@ def parse(string):
string -- string to be parsed
"""
dt = dateutil.parser.parse(string)
return MayaDT.from_datetime(dt)
return MayaDT.from_datetime(dt)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author='Kenneth Reitz',
author_email='[email protected]',
url='https://github.com/kennethreitz/maya',
my_modules=['maya'],
py_modules=['maya'],
install_requires=required,
license='MIT',
classifiers=(
Expand Down
29 changes: 28 additions & 1 deletion test_maya.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pytest
from datetime import datetime

import maya


Expand Down Expand Up @@ -43,10 +46,29 @@ def test_dt_tz_naive():


def test_random_date():
d = maya.when('11-17-11')
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


def test_print_date(capsys):
d = maya.when('11-17-11')

print(d)
out, err = capsys.readouterr()
assert out == '<MayaDT epoch=1321488000.0>\n'

assert type(d.__format__()) is datetime


def test_invalid_date():
with pytest.raises(ValueError):
d = maya.when('another day')


def test_slang_date():
Expand All @@ -58,4 +80,9 @@ def test_slang_time():
d = maya.when('one hour ago')
assert d.slang_time() == 'an hour ago'


def test_format():
d = maya.parse('February 21, 1994')
assert format(d) == format(d.datetime())

# rand_day = maya.when('2011-02-07', timezone='US/Eastern')

0 comments on commit be29d01

Please sign in to comment.