devilry.utils.datetimeutils.ISODATETIME_DJANGOFORMAT = 'Y-m-d H:i'

Django datetime formatting string for YYYY-MM-DD hh:mm.


Get the current datetime as a datetime.datetime object.

We use this because it is easier to mock in unit tests than a built-in or third party implementation.

devilry.utils.datetimeutils.default_timezone_datetime(*args, **kwargs)

Create a timezone-aware datetime.datetime object.

The parameters are the same as for datetime.datetime.


Format the given datetime.datetime object as YYYY-MM-DD hh:mm.


Format the given datetime.datetime object as YYYY-MM-DD hh:mm.

devilry.utils.datetimeutils.datetime_with_same_day_of_week_and_time(weekdayandtimesource_datetime, target_datetime)

Returns a new datetime object with the same time and day of week as the given target_datetime, with the day of week moved forward to match the weekdayandtimesource_datetime, and the time matching the weekdayandtimesource_datetime.

This means that if you send in a weekdayandtimesource_datetime with tuesday as the weekday, the return value will be a datetime object with the day set to the next tuesday unless the current day is monday or tuesday.


Converts datetime object to URL-friendly string.


datetime_obj (django.utils.timezone) – datetime obj to convert.


Datetime as string specified by URL_DATETIME_FORMAT.

Return type:



Convert URL-friendly string to django.utils.timezone datetime object. :param datetime_string: String to convert. :type datetime_string: str


Converted datetime object from string.

Return type: