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.
parse_single_date¶
def parse_single_date(
date_str: str
) -> datetime.datetime
Parse a single RFC3339 date string into a datetime object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date_str | str | A string representing the date in RFC3339 format. | None |
Returns:
Type | Description |
---|---|
datetime | A datetime object parsed from the date_str. |
Raises:
Type | Description |
---|---|
ValueError | If the date_str is empty or contains the placeholder '..'. |
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: Optional[str]
) -> Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType]
Extract a tuple of datetime objects from an interval string defined by the OGC API.
The interval can either be a single datetime or a range with start and end datetime.
Args: interval (Optional[str]): The interval string to convert to datetime objects, or None if no datetime is specified.
Returns: Optional[DateTimeType]: A tuple of datetime.datetime objects or None if input is None.
Raises: HTTPException: If the string is not valid for various reasons such as being empty, having more than one slash, or if date formats are invalid.