libcloud.utils.iso8601 module

Copyright (c) 2007 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. ISO 8601 date time string parsing

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

exception libcloud.utils.iso8601.ParseError[source]

Bases: Exception

Raised when there is a problem parsing a date string

libcloud.utils.iso8601.parse_date(datestring, default_timezone=<libcloud.utils.iso8601.Utc object>, allow_empty=False)[source]

Parses ISO 8601 dates into datetime objects

The timezone is parsed from the date string. However it is quite common to have dates without a timezone (not strictly correct). In this case the default timezone specified in default_timezone is used. This is UTC by default.

libcloud.utils.iso8601.parse_date_allow_empty(datestring, default_timezone=<libcloud.utils.iso8601.Utc object>)[source]

Parses ISO 8601 dates into datetime objects, but allow empty values.

In case empty value is found, None is returned.