Compare commits

..

16 Commits

Author SHA1 Message Date
kennethreitz be29d01160 Merge branch 'master' of github.com:kennethreitz/maya 2016-12-18 12:43:02 -05:00
kennethreitz 5e4853936b Merge pull request #8 from timofurrer/bugfix/format
Fix formatting MayaDT object
2016-12-18 09:41:58 -08:00
kennethreitz 7dbe450c28 Merge pull request #12 from djrobstep/bugfix/py-modules
my_modules -> py_modules
2016-12-18 09:41:29 -08:00
kennethreitz 3ce6734a5e Merge pull request #13 from grigouze/add_tests_for_coverage
Just add some tests to have full coverage
2016-12-18 09:41:12 -08:00
kennethreitz 6e2f530207 Merge pull request #7 from Kraymer/patch-1
Update README.rst (typo)
2016-12-18 09:40:04 -08:00
Grigouze c46d9874d4 Just add some tests to have full coverage
Now it's 💯 % coverage, i don't if it's good or bad but it was easy :)
2016-12-18 15:12:02 +01:00
Robert Lechte 87013d71e0 my_modules -> py_modules 2016-12-18 22:38:40 +11:00
Timo Furrer a562f48e24 Fix formatting MayaDT object 2016-12-18 10:59:22 +01:00
Fabrice Laporte 8fc07b3ab3 Update README.rst
Typo tomorrrow => tomorrow
2016-12-18 10:39:43 +01:00
kennethreitz 59064a5c50 Merge pull request #5 from uranusjr/master
Fix typos in README and add pip install instruction
2016-12-18 00:58:43 -08:00
Tzu-ping Chung 7ae84f3266 Add pip install instruction 2016-12-18 16:04:23 +08:00
Tzu-ping Chung cc668974b6 Fix typos 2016-12-18 16:03:35 +08:00
kennethreitz 6a4ddff215 Update README.rst 2016-12-18 02:48:45 -05:00
kennethreitz a0ab4fc3fb Update README.rst 2016-12-18 02:48:29 -05:00
kennethreitz c80ecad67b Update README.rst 2016-12-18 02:48:12 -05:00
kennethreitz 97842c01b3 Update README.rst 2016-12-18 02:47:57 -05:00
4 changed files with 40 additions and 8 deletions
+9 -4
View File
@@ -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()
@@ -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
-----------------
@@ -73,3 +73,8 @@ Installation is easy, with pip::
$ pip install maya
✨🍰✨
☤ Like it?
----------
`Say Thanks <https://saythanks.io/to/kennethreitz>`_!
+2 -2
View File
@@ -34,7 +34,7 @@ class MayaDT(object):
def __format__(self, *args, **kwargs):
"""Return's the datetime's format"""
return self.datetime(*args, **kwargs)
return format(self.datetime(*args, **kwargs))
# Timezone Crap
# -------------
@@ -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)
+1 -1
View File
@@ -27,7 +27,7 @@ setup(
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
url='https://github.com/kennethreitz/maya',
my_modules=['maya'],
py_modules=['maya'],
install_requires=required,
license='MIT',
classifiers=(
+28 -1
View File
@@ -1,3 +1,6 @@
import pytest
from datetime import datetime
import maya
@@ -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():
@@ -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')