mirror of
https://github.com/kennethreitz/maya.git
synced 2026-06-05 23:00:18 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be29d01160 | |||
| 5e4853936b | |||
| 7dbe450c28 | |||
| 3ce6734a5e | |||
| 6e2f530207 | |||
| c46d9874d4 | |||
| 87013d71e0 | |||
| a562f48e24 | |||
| 8fc07b3ab3 | |||
| 59064a5c50 | |||
| 7ae84f3266 | |||
| cc668974b6 | |||
| 6a4ddff215 | |||
| a0ab4fc3fb | |||
| c80ecad67b | |||
| 97842c01b3 |
+9
-4
@@ -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>`_!
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user