Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

python-aniso8601

Repository Summary

Checkout URI https://bitbucket.org/nielsenb/aniso8601.git
VCS Type git
VCS Version v0.83
Last Updated 2014-08-06
Dev Status MAINTAINED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
python-aniso8601 0.8.3

README

aniso8601

Another ISO 8601 parser for Python

Features

  • Pure Python implementation
  • Python 3 support
  • No extra dependencies
  • Logical behavior
  • UTC offset represented as fixed-offset tzinfo
  • No regular expressions

Installation

The recommended installation method is to use pip:

$ pip install aniso8601

Alternatively, you can download the source (git repository hosted at Bitbucket) and install directly:

$ python setup.py install

Use

Parsing datetimes

To parse a typical ISO 8601 datetime string:

>>> import aniso8601
>>> aniso8601.parse_datetime('1977-06-10T12:00:00Z')
datetime.datetime(1977, 6, 10, 12, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbd90>)

Alternative delimiters can be specified, for example, a space:

>>> aniso8601.parse_datetime('1977-06-10 12:00:00Z', delimiter=' ')
datetime.datetime(1977, 6, 10, 12, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbf50>)

UTC offsets are supported:

>>> aniso8601.parse_datetime('1979-06-05T08:00:00-08:00')
datetime.datetime(1979, 6, 5, 8, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbf50>)

If a UTC offset is not specified, the returned datetime will be naive:

>>> aniso8601.parse_datetime('1983-01-22T08:00:00')
datetime.datetime(1983, 1, 22, 8, 0)

Parsing dates

To parse a date represented in an ISO 8601 string:

>>> import aniso8601
>>> aniso8601.parse_date('1984-04-23')
datetime.date(1984, 4, 23)

Basic format is supported as well:

>>> aniso8601.parse_date('19840423')
datetime.date(1984, 4, 23)

To parse a date using the ISO 8601 week date format:

>>> aniso8601.parse_date('1986-W38-1')
datetime.date(1986, 9, 15)

To parse an ISO 8601 ordinal date:

>>> aniso8601.parse_date('1988-132')
datetime.date(1988, 5, 11)

Parsing times

To parse a time formatted as an ISO 8601 string:

>>> import aniso8601
>>> aniso8601.parse_time('11:31:14')
datetime.time(11, 31, 14)

As with all of the above, basic format is supported:

>>> aniso8601.parse_time('113114')
datetime.time(11, 31, 14)

A UTC offset can be specified for times:

File truncated at 100 lines see the full file

Repo symbol

python-aniso8601 repository

python-aniso8601

Repository Summary

Checkout URI https://bitbucket.org/nielsenb/aniso8601.git
VCS Type git
VCS Version v0.83
Last Updated 2014-08-06
Dev Status MAINTAINED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
python-aniso8601 0.8.3

README

aniso8601

Another ISO 8601 parser for Python

Features

  • Pure Python implementation
  • Python 3 support
  • No extra dependencies
  • Logical behavior
  • UTC offset represented as fixed-offset tzinfo
  • No regular expressions

Installation

The recommended installation method is to use pip:

$ pip install aniso8601

Alternatively, you can download the source (git repository hosted at Bitbucket) and install directly:

$ python setup.py install

Use

Parsing datetimes

To parse a typical ISO 8601 datetime string:

>>> import aniso8601
>>> aniso8601.parse_datetime('1977-06-10T12:00:00Z')
datetime.datetime(1977, 6, 10, 12, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbd90>)

Alternative delimiters can be specified, for example, a space:

>>> aniso8601.parse_datetime('1977-06-10 12:00:00Z', delimiter=' ')
datetime.datetime(1977, 6, 10, 12, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbf50>)

UTC offsets are supported:

>>> aniso8601.parse_datetime('1979-06-05T08:00:00-08:00')
datetime.datetime(1979, 6, 5, 8, 0, tzinfo=<aniso8601.UTCOffset object at 0x7f44fadbbf50>)

If a UTC offset is not specified, the returned datetime will be naive:

>>> aniso8601.parse_datetime('1983-01-22T08:00:00')
datetime.datetime(1983, 1, 22, 8, 0)

Parsing dates

To parse a date represented in an ISO 8601 string:

>>> import aniso8601
>>> aniso8601.parse_date('1984-04-23')
datetime.date(1984, 4, 23)

Basic format is supported as well:

>>> aniso8601.parse_date('19840423')
datetime.date(1984, 4, 23)

To parse a date using the ISO 8601 week date format:

>>> aniso8601.parse_date('1986-W38-1')
datetime.date(1986, 9, 15)

To parse an ISO 8601 ordinal date:

>>> aniso8601.parse_date('1988-132')
datetime.date(1988, 5, 11)

Parsing times

To parse a time formatted as an ISO 8601 string:

>>> import aniso8601
>>> aniso8601.parse_time('11:31:14')
datetime.time(11, 31, 14)

As with all of the above, basic format is supported:

>>> aniso8601.parse_time('113114')
datetime.time(11, 31, 14)

A UTC offset can be specified for times:

File truncated at 100 lines see the full file

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository

Repo symbol

python-aniso8601 repository