tincan.conversions package

Submodules

tincan.conversions.iso8601 module

Functions for converting datetime.timedelta and datetime.datetime to and from ISO 8601 strings.

tincan.conversions.iso8601.jsonify_datetime(value)
tincan.conversions.iso8601.jsonify_timedelta(value)

Converts a datetime.timedelta to an ISO 8601 duration string for JSON-ification.

Parameters:value (datetime.timedelta) – something to convert
Returns:the value after conversion

:rtype unicode

tincan.conversions.iso8601.make_datetime(value)

Tries to convert the given value to a datetime.datetime. If no timezone is given, raises a ValueError.

Strings will be parsed as ISO 8601 timestamps.

If a number is provided, it will be interpreted as a UNIX timestamp, which by definition is UTC.

If a dict is provided, does datetime.datetime(**value).

If a tuple or a list is provided, does datetime.datetime(*value). Uses the timezone in the tuple or list if provided.

Parameters:value (str | unicode | float | int | datetime.datetime | dict | list | tuple) – something to convert
Returns:the value after conversion
Return type:datetime.datetime
Raises:ValueError | TypeError
tincan.conversions.iso8601.make_timedelta(value)

Tries to convert the given value to a datetime.timedelta.

Strings will be parsed as ISO 8601 durations.

If a number is provided, it will be interpreted as the number of seconds.

If a dict is provided, does datetime.timedelta(**value).

Parameters:value (str | unicode | float | int | datetime.timedelta | dict) – something to convert
Returns:the value after conversion
Return type:datetime.timedelta
tincan.conversions.iso8601.tuple_to_datetime(value)

Module contents

Table Of Contents

Previous topic

tincan package

Next topic

tincan.documents package

This Page