Documentation

datetime.start_of

Return a datetime set to be the start of some unit of time given by unit. Acceptable values for unit are "hour", "day", "week", "month", and "year".

If the unit is set to "week", the start of the week is considered Monday at 12:00 AM.

Arguments:

def datetime.start_of(
  dt: <datetime> = None,
  unit: <str> = None, # 'hour', 'day', 'week', 'month', or 'year'
):

Returns <datetime>.

Example:

long_long_ago = datetime.from_date_and_time(
  year=1995,
  month=1,
  day=15,
  hour=0,
  minute=0,
  second=0)
  
# start_of_1995 == January 1 1995 00:00:00
start_of_1995 = datetime.start_of(dt=long_long_ago, unit='year')