Skip to content

Module stac_fastapi.core.datetime_utils

A few datetime methods.

Functions

datetime_to_str

def datetime_to_str(
    dt: datetime.datetime,
    timespec: str = 'auto'
) -> str

Convert a :class:datetime.datetime instance to an ISO8601 string in the `RFC 3339, section 5.6.

datatracker.ietf.org/doc/html/rfc3339#section-5.6__ format required by the :stac-spec:STAC Spec `.

Parameters:

Name Type Description Default
dt None The datetime to convert. None
timespec None An optional argument that specifies the number of additional
terms of the time to include. Valid options are 'auto', 'hours',
'minutes', 'seconds', 'milliseconds' and 'microseconds'. The default value
is 'auto'.
None

Returns:

Type Description
str The ISO8601 (RFC 3339) formatted string representing the datetime.

now_in_utc

def now_in_utc(

) -> datetime.datetime

Return a datetime value of now with the UTC timezone applied.

now_to_rfc3339_str

def now_to_rfc3339_str(

) -> str

Return an RFC 3339 string representing now.