current_datetime#

safir.datetime.current_datetime()#

Construct a datetime for the current time.

Databases do not always store microseconds in time fields, and having some dates with microseconds and others without them can lead to bugs. It’s also easy to forget to force all datetime objects to be time zone aware. This function avoids both problems by forcing UTC and forcing microseconds to 0.

Returns:

The current time forced to UTC and with the microseconds field zeroed.

Return type:

datetime.datetime