asphalt.tasks.util

asphalt.tasks.util.as_timezone(obj)

Interpret an object as a pytz timezone.

Parameters:obj (Union[UTC, DstTzInfo, str]) – either the name of a timezone (e.g. Europe/Helsinki) or a pytz timezone
Return type:Union[UTC, DstTzInfo, None]
Returns:a pytz timezone
asphalt.tasks.util.convert_to_timezone(value, timezone)

Convert the given object to a timezone aware datetime object.

If a timezone aware datetime object is passed, it is converted to the given timezone. If a naïve datetime object is passed, it is given the specified timezone.

Parameters:
  • value (Optional[datetime]) – the datetime to convert to a timezone aware datetime
  • timezone (Union[UTC, DstTzInfo]) – timezone to interpret value in
Return type:

Optional[datetime]

Returns:

a timezone aware datetime

asphalt.tasks.util.create_reference(obj)

Return a module:varname reference to the given object.

Return type:str
asphalt.tasks.util.datetime_ceil(timeval)

Round the given datetime object upwards to the nearest full second.

Return type:datetime