Skip to content

Module stac_fastapi.types.rfc3339

rfc3339.

Variables

DateTimeType
RFC33339_PATTERN

Functions

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.

rfc3339_str_to_datetime

def rfc3339_str_to_datetime(
    s: str
) -> datetime.datetime

Convert a string conforming to RFC 3339 to a :class:datetime.datetime.

Uses :meth:iso8601.parse_date under the hood.

Parameters:

Name Type Description Default
s str The string to convert to :class:datetime.datetime. None

Returns:

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

Raises:

Type Description
ValueError If the string is not a valid RFC 3339 string.

str_to_interval

def str_to_interval(
    interval: str
) -> Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType]

Extract a tuple of datetimes from an interval string.

Interval strings are defined by OGC API - Features Part 1 for the datetime query parameter value. These follow the form '1985-04-12T23:20:50.52Z/1986-04-12T23:20:50.52Z', and allow either the start or end (but not both) to be open-ended with '..' or ''.

Args: interval (str) : The interval string to convert to a :class:datetime.datetime tuple.

Raises: ValueError: If the string is not a valid interval string.