Compare commits

..

16 Commits

Author SHA1 Message Date
kennethreitz 2fce84195e v0.1.4 2016-12-21 13:24:53 -05:00
kennethreitz 7ab9e48d45 Merge pull request #25 from Factr/master
Added .gitignore
2016-12-20 22:19:15 -05:00
Adam Nelson ee1a8e2438 Added .gitignore
From https://github.com/github/gitignore/blob/master/Python.gitignore with Pycharm exclusion for .idea/
2016-12-20 16:08:29 -05:00
kennethreitz b0e91d6c0e Merge pull request #24 from Factr/master
Added tzlocal to setup.py
2016-12-20 14:30:11 -05:00
Adam Nelson bce5d13401 Merge branch 'master' of github.com:Factr/maya into HEAD 2016-12-20 13:36:19 -05:00
Adam Nelson b4a23d668d Added tzlocal as setup requirement 2016-12-20 13:34:49 -05:00
kennethreitz 90051da96d fix maya link to travis 2016-12-20 13:09:48 -05:00
kennethreitz 8f0ff0d68c skip 3 builds 2016-12-20 13:08:55 -05:00
kennethreitz fd1262a8e8 shields 2016-12-20 12:57:11 -05:00
kennethreitz 7558261dc8 basic travis file 2016-12-20 12:49:56 -05:00
kennethreitz 1407e688fd improve test name 2016-12-20 12:29:31 -05:00
kennethreitz 0c2b936111 cleanup tests 2016-12-20 12:27:16 -05:00
kennethreitz 9e72ef3d2f test for #19 2016-12-20 12:25:19 -05:00
kennethreitz eabba0b79e v0.1.3 2016-12-20 12:25:01 -05:00
kennethreitz 8af92bc33c fixes #19 2016-12-20 12:20:50 -05:00
Adam Nelson 0efc489ba1 Added tzlocal as a requirement as well 2016-12-19 17:15:35 -05:00
6 changed files with 128 additions and 7 deletions
+94
View File
@@ -0,0 +1,94 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
.venv/
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# PyCharm
.idea/
+8
View File
@@ -0,0 +1,8 @@
language: python
python:
- "2.7"
# - "3.5" # looks like ruamel.ordereddict doesn't build for python3
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: make
+11 -1
View File
@@ -1,6 +1,16 @@
Maya: Datetime for Humans™
==========================
.. image:: https://img.shields.io/pypi/v/maya.svg
:target: https://pypi.python.org/pypi/maya
.. image:: https://travis-ci.org/kennethreitz/maya.svg?branch=master
:target: https://travis-ci.org/kennethreitz/maya
.. image:: https://img.shields.io/badge/SayThanks.io-☼-1EAEDB.svg
:target: https://saythanks.io/to/kennethreitz
Datetimes are very frustrating to work with in Python, especially when dealing
with different locales on different systems. This library exists to make the
simple things **much** easier, while admitting that time is an illusion
@@ -61,7 +71,7 @@ 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`).
- 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 carries a towel.
+5 -1
View File
@@ -104,12 +104,16 @@ class MayaDT(object):
dt = self.datetime().astimezone(pytz.timezone(to_timezone))
else:
dt = Datetime.utcfromtimestamp(self._epoch)
dt.replace(tzinfo=self._tz)
# Strip the timezone info if requested to do so.
if naive:
return dt.replace(tzinfo=None)
else:
if dt.tzinfo is None:
dt = dt.replace(tzinfo=self._tz)
return dt.replace(tzinfo=self._tz)
return dt
def iso8601(self):
"""Returns an ISO 8601 representation of the MayaDT."""
+3 -2
View File
@@ -29,12 +29,13 @@ required = [
'dateparser',
'iso8601',
'python-dateutil',
'ruamel.yaml'
'ruamel.yaml',
'tzlocal'
]
setup(
name='maya',
version='0.1.2',
version='0.1.4',
description='Datetimes for Humans.',
long_description= '\n' + read('README.rst'),
author='Kenneth Reitz',
+7 -3
View File
@@ -66,7 +66,7 @@ def test_print_date(capsys):
def test_invalid_date():
with pytest.raises(ValueError):
d = maya.when('another day')
maya.when('another day')
def test_slang_date():
@@ -79,7 +79,7 @@ def test_slang_time():
assert d.slang_time() == 'an hour ago'
def test_format():
def test_parse():
d = maya.parse('February 21, 1994')
assert format(d) == '1994-02-21 00:00:00+00:00'
@@ -89,4 +89,8 @@ def test_format():
d = maya.parse('01/05/2016', day_first=True)
assert format(d) == '2016-05-01 00:00:00+00:00'
# rand_day = maya.when('2011-02-07', timezone='US/Eastern')
def test_datetime_to_timezone():
dt = maya.when('2016-01-01').datetime(to_timezone='US/Eastern')
assert dt.tzinfo.zone == 'US/Eastern'