Skip to content

Commit

Permalink
Bundle pyiso8601 for iso8601 time/date manipulation.
Browse files Browse the repository at this point in the history
(corrected lib/update-external.sh by Andrew Bartlett)

Change-Id: I0f992b949b1717635ff26fa0db6073675cce4ad7
Signed-Off-By: Jelmer Vernooij <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Garming Sam <[email protected]>
  • Loading branch information
jelmer authored and abartlet committed Mar 6, 2015
1 parent 039fa93 commit 13bd83a
Show file tree
Hide file tree
Showing 17 changed files with 1,337 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/update-external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ svn co http://mimeparse.googlecode.com/svn/trunk/ "$WORKDIR/mimeparse"
rm -rf "$WORKDIR/mimeparse/.svn"
rsync -avz --delete "$WORKDIR/mimeparse/" "$LIBDIR/mimeparse/"

echo "Updating pyiso8601..."
hg clone https://bitbucket.org/micktwomey/pyiso8601 "$WORKDIR/pyiso8601"
rm -rf "$WORKDIR/pyiso8601/.hg"
rsync -avz --delete "$WORKDIR/pyiso8601/" "$THIRD_PARTY_DIR/pyiso8601/"

rm -rf "$WORKDIR"
8 changes: 8 additions & 0 deletions third_party/pyiso8601/.hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax: glob
build
dist
*.pyc
iso8601.egg-info
pyiso8601-venv
.tox
_build
6 changes: 6 additions & 0 deletions third_party/pyiso8601/.hgtags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bd89974951dae66bdb1c441d2e931f6b27fe1097 0.1.5
462f8303fc3995150c188d3708fb6981d7705453 0.1.6
1881bf20e595e5b923f5c8b1f859dc310e5f22c2 0.1.7
01161826be6e8a99cde813850f0d6ed7952ff377 0.1.8
4b511368cef17b3648af3bc16d2421ce8fbe4dc8 0.1.9
0f02cc55100a1bad23c0ea0bd0f07b8de0e3e3f0 0.1.10
20 changes: 20 additions & 0 deletions third_party/pyiso8601/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2007 - 2014 Michael Twomey

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions third_party/pyiso8601/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include iso8601 *.py
include README.rst LICENSE tox.ini setup.py *requirements.txt
180 changes: 180 additions & 0 deletions third_party/pyiso8601/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
Simple module to parse ISO 8601 dates

This module parses the most common forms of ISO 8601 date strings (e.g.
2007-01-14T20:34:22+00:00) into datetime objects.

>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>>

See the LICENSE file for the license this package is released under.

If you want more full featured parsing look at:

- http://labix.org/python-dateutil - python-dateutil

Parsed Formats
==============

You can parse full date + times, or just the date. In both cases a datetime instance is returned but with missing times defaulting to 0, and missing days / months defaulting to 1.

Dates
-----

- YYYY-MM-DD
- YYYYMMDD
- YYYY-MM (defaults to 1 for the day)
- YYYY (defaults to 1 for month and day)

Times
-----

- hh:mm:ss.nn
- hhmmss.nn
- hh:mm (defaults to 0 for seconds)
- hhmm (defaults to 0 for seconds)
- hh (defaults to 0 for minutes and seconds)

Time Zones
----------

- Nothing, will use the default timezone given (which in turn defaults to UTC).
- Z (UTC)
- +/-hh:mm
- +/-hhmm
- +/-hh

Where it Differs From ISO 8601
==============================

Known differences from the ISO 8601 spec:

- You can use a " " (space) instead of T for separating date from time.
- Days and months without a leading 0 (2 vs 02) will be parsed.
- If time zone information is omitted the default time zone given is used (which in turn defaults to UTC). Use a default of None to yield naive datetime instances.

Homepage
========

- Documentation: http://pyiso8601.readthedocs.org/
- Source: https://bitbucket.org/micktwomey/pyiso8601/

This was originally hosted at https://code.google.com/p/pyiso8601/

References
==========

- http://en.wikipedia.org/wiki/ISO_8601

- http://www.cl.cam.ac.uk/~mgk25/iso-time.html - simple overview

- http://hydracen.com/dx/iso8601.htm - more detailed enumeration of valid formats.

Testing
=======

1. pip install -r dev-requirements.txt
2. tox

Note that you need all the pythons installed to perform a tox run (see below). Homebrew helps a lot on the mac, however you wind up having to add cellars to your PATH or symlinking the pythonX.Y executables.

Alternatively, to test only with your current python:

1. pip install -r dev-requirements.txt
2. py.test --verbose iso8601

Supported Python Versions
=========================

Tested against:

- Python 2.6
- Python 2.7
- Python 3.2
- Python 3.3
- Python 3.4
- PyPy

Python 3.0 and 3.1 are untested but should work (tests didn't run under them when last tried).

Jython is untested but should work (tests failed to run).

Python 2.5 is not supported (too old for the tests for the most part). It could work with some small changes but I'm not supporting it.

Changes
=======

0.1.11
------

* Add Python 3.4 to tox test config.
* Add PyPy 3 to tox test config.
* Link to documentation at http://pyiso8601.readthedocs.org/


0.1.10
------

* Fixes https://bitbucket.org/micktwomey/pyiso8601/issue/14/regression-yyyy-mm-no-longer-parses (thanks to Kevin Gill for reporting)
* Adds YYYY as a valid date (uses 1 for both month and day)
* Woo, semantic versioning, .10 at last.

0.1.9
-----

* Lots of fixes tightening up parsing from jdanjou. In particular more invalid cases are treated as errors. Also includes fixes for tests (which is how these invalid cases got in in the first place).
* Release addresses https://bitbucket.org/micktwomey/pyiso8601/issue/13/new-release-based-on-critical-bug-fix

0.1.8
-----

* Remove +/- chars from README.rst and ensure tox tests run using LC_ALL=C. The setup.py egg_info command was failing in python 3.* on some setups (basically any where the system encoding wasn't UTF-8). (https://bitbucket.org/micktwomey/pyiso8601/issue/10/setuppy-broken-for-python-33) (thanks to klmitch)

0.1.7
-----

* Fix parsing of microseconds (https://bitbucket.org/micktwomey/pyiso8601/issue/9/regression-parsing-microseconds) (Thanks to dims and bnemec)

0.1.6
-----

* Correct negative timezone offsets (https://bitbucket.org/micktwomey/pyiso8601/issue/8/015-parses-negative-timezones-incorrectly) (thanks to Jonathan Lange)

0.1.5
-----

* Wow, it's alive! First update since 2007
* Moved over to https://bitbucket.org/micktwomey/pyiso8601
* Add support for python 3. https://code.google.com/p/pyiso8601/issues/detail?id=23 (thanks to zefciu)
* Switched to py.test and tox for testing
* Make seconds optional in date format ("1997-07-16T19:20+01:00" now valid). https://bitbucket.org/micktwomey/pyiso8601/pull-request/1/make-the-inclusion-of-seconds-optional-in/diff (thanks to Chris Down)
* Correctly raise ParseError for more invalid inputs (https://bitbucket.org/micktwomey/pyiso8601/issue/1/raise-parseerror-for-invalid-input) (thanks to manish.tomar)
* Support more variations of ISO 8601 dates, times and time zone specs.
* Fix microsecond rounding issues (https://bitbucket.org/micktwomey/pyiso8601/issue/2/roundoff-issues-when-parsing-decimal) (thanks to [email protected])
* Fix pickling and deepcopy of returned datetime objects (https://bitbucket.org/micktwomey/pyiso8601/issue/3/dates-returned-by-parse_date-do-not) (thanks to fogathmann and [email protected])
* Fix timezone offsets without a separator (https://bitbucket.org/micktwomey/pyiso8601/issue/4/support-offsets-without-a-separator) (thanks to joe.walton.gglcd)
* "Z" produces default timezone if one is specified (https://bitbucket.org/micktwomey/pyiso8601/issue/5/z-produces-default-timezone-if-one-is) (thanks to vfaronov). This one may cause problems if you've been relying on default_timezone to use that timezone instead of UTC. Strictly speaking that was wrong but this is potentially backwards incompatible.
* Handle compact date format (https://bitbucket.org/micktwomey/pyiso8601/issue/6/handle-compact-date-format) (thanks to [email protected])

0.1.4
-----

* The default_timezone argument wasn't being passed through correctly, UTC was being used in every case. Fixes issue 10.

0.1.3
-----

* Fixed the microsecond handling, the generated microsecond values were way too small. Fixes issue 9.

0.1.2
-----

* Adding ParseError to __all__ in iso8601 module, allows people to import it. Addresses issue 7.
* Be a little more flexible when dealing with dates without leading zeroes. This violates the spec a little, but handles more dates as seen in the field. Addresses issue 6.
* Allow date/time separators other than T.

0.1.1
-----

* When parsing dates without a timezone the specified default is used. If no default is specified then UTC is used. Addresses issue 4.
5 changes: 5 additions & 0 deletions third_party/pyiso8601/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
devpi>=1.2.1
pytest>=2.5.2
Sphinx>=1.2.1
tox>=1.7.0
wheel>=0.22.0
Loading

0 comments on commit 13bd83a

Please sign in to comment.