utilities

This module contains utility functions for parsing various strings.

Functions

parse_datetime(string, default_timezone)[source]

Parse a timestamp string. If the timestamp does not specify a timezone, default_timezone is used.

Parameters:
  • string (str) – The string to parse.

  • default_timezone (datetime.tzinfo) – The default timezone to set.

Return type:

datetime.datetime

parse_float(string)[source]

Parse a literal string representing a floating point value.

Parameters:

string (str) – The string to parse.

Return type:

decimal.Decimal

parse_timedelta(string)[source]

Parse a literal string representing a time period in the ISO-8601 duration format.

Parameters:

string (str) – The string to parse.

Return type:

datetime.timedelta