tron.utils.trontimespec module

A complete time specification based on the Google App Engine GROC spec.

class tron.utils.trontimespec.TimeSpecification(ordinals=None, weekdays=None, months=None, monthdays=None, timestr=None, timezone=None, minutes=None, hours=None, seconds=None)

Bases: object

TimeSpecification determines the next time which matches the configured pattern.

get_match(start)

Returns the next datetime match after start.

handle_timezone(out, tzinfo)
next_day(first_day, year, month)

Returns matching days for the given year and month.

next_month(start_date)

Create a generator which yields valid months after the start month.

next_time(start_date, is_start_day)

Return the next valid time.

tron.utils.trontimespec.get_time(time_string)

Converts a string to a datetime.time object.

Arguments:

time_string: a string representing a time (‘hours:minutes’)

Returns:

a datetime.time object

tron.utils.trontimespec.get_timezone(timezone_string)

Converts a timezone string to a pytz timezone object.

Arguments:

timezone_string: a string representing a timezone, or None

Returns:

a pytz timezone object, or None if the input timezone_string is None

Raises:
ValueError: if timezone_string is not None and the pytz module could not be

loaded

tron.utils.trontimespec.naive_as_timezone(t, tzinfo)

Interprets the naive datetime with the given time zone.

tron.utils.trontimespec.to_timezone(t, tzinfo)

Converts ‘t’ to the time zone ‘tzinfo’.

Arguments:
t: a datetime object. It may be in any pytz time zone, or it may be

timezone-naive (interpreted as UTC).

tzinfo: a pytz timezone object, or None (interpreted as UTC).

Returns:

a datetime object in the time zone ‘tzinfo’

tron.utils.trontimespec.validate_spec(source, value_range, type, default=None, allow_last=False)