iceberg-cpp
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
iceberg::TemporalUtils Class Reference

Static Public Member Functions

static int64_t NanosToMicros (int64_t nanos)
 Convert nanoseconds since epoch to microseconds using floor division.
 
static Result< int64_t > MicrosToNanos (int64_t micros)
 Convert microseconds since epoch to nanoseconds, failing on overflow.
 
static Result< int32_t > ParseDay (std::string_view str)
 Parses a date string in "[+-]yyyy-MM-dd" format into days since epoch.
 
static Result< int64_t > ParseTime (std::string_view str)
 Parses a time string into microseconds from midnight.
 
static Result< int64_t > ParseTimeNs (std::string_view str)
 Parses a time string into nanoseconds from midnight.
 
static Result< int64_t > ParseTimestamp (std::string_view str)
 Parses a timestamp string into microseconds since epoch.
 
static Result< int64_t > ParseTimestampNs (std::string_view str)
 Parses a timestamp string into nanoseconds since epoch.
 
static Result< int64_t > ParseTimestampWithZone (std::string_view str)
 Parses a timestamp-with-zone string into microseconds since epoch (UTC).
 
static Result< int64_t > ParseTimestampNsWithZone (std::string_view str)
 Parses a timestamp-with-zone string into nanoseconds since epoch (UTC).
 
static Result< bool > IsUtcOffset (std::string_view str)
 Reports whether a timestamp-with-zone string carries a zero (UTC) offset.
 
static Result< LiteralExtractYear (const Literal &literal)
 Extract a date or timestamp year, as years from 1970.
 
static Result< LiteralExtractMonth (const Literal &literal)
 Extract a date or timestamp month, as months from 1970-01-01.
 
static Result< LiteralExtractDay (const Literal &literal)
 Extract a date or timestamp day, as days from 1970-01-01.
 
static Result< LiteralExtractHour (const Literal &literal)
 Extract a timestamp hour, as hours from 1970-01-01 00:00:00.
 

Member Function Documentation

◆ IsUtcOffset()

Result< bool > iceberg::TemporalUtils::IsUtcOffset ( std::string_view  str)
static

Reports whether a timestamp-with-zone string carries a zero (UTC) offset.

The ParseTimestamp*WithZone parsers accept any offset and silently normalize it to UTC. The spec's JSON single-value form for timestamptz / timestamptz_ns default values is meant to be UTC, so callers that must enforce that rule check the offset here before parsing.

Any zero-offset spelling is treated as UTC: "Z", "+00:00" and "-00:00" all denote a zero offset and are accepted, even though the spec writes the canonical form as "+00:00". Only a genuinely non-zero offset (e.g. "+05:00") is rejected.

Parameters
strThe timestamp-with-zone string to inspect.
Returns
true if the offset is zero, false if it is a non-zero offset, or an error if the timezone suffix cannot be parsed.

◆ ParseDay()

Result< int32_t > iceberg::TemporalUtils::ParseDay ( std::string_view  str)
static

Parses a date string in "[+-]yyyy-MM-dd" format into days since epoch.

Supports an optional '+' or '-' prefix for extended years beyond 9999.

Parameters
strThe date string to parse.
Returns
The number of days since 1970-01-01, or an error.

◆ ParseTime()

Result< int64_t > iceberg::TemporalUtils::ParseTime ( std::string_view  str)
static

Parses a time string into microseconds from midnight.

Accepts ISO-8601 local time formats: "HH:mm", "HH:mm:ss", or "HH:mm:ss.f" where the fractional part can be 1-9 digits. Digits beyond 6 (microsecond precision) are truncated.

Parameters
strThe time string to parse.
Returns
The number of microseconds from midnight, or an error.

◆ ParseTimeNs()

Result< int64_t > iceberg::TemporalUtils::ParseTimeNs ( std::string_view  str)
static

Parses a time string into nanoseconds from midnight.

Accepts ISO-8601 local time formats: "HH:mm", "HH:mm:ss", or "HH:mm:ss.f" where the fractional part can be 1-9 digits. Digits beyond 9 (nanosecond precision) are truncated.

Parameters
strThe time string to parse.
Returns
The number of nanoseconds from midnight, or an error.

◆ ParseTimestamp()

Result< int64_t > iceberg::TemporalUtils::ParseTimestamp ( std::string_view  str)
static

Parses a timestamp string into microseconds since epoch.

Accepts ISO-8601 local date-time formats: "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss", or "yyyy-MM-ddTHH:mm:ss.f" where the fractional part can be 1-9 digits (truncated to microseconds).

Parameters
strThe timestamp string to parse.
Returns
The number of microseconds since epoch, or an error.

◆ ParseTimestampNs()

Result< int64_t > iceberg::TemporalUtils::ParseTimestampNs ( std::string_view  str)
static

Parses a timestamp string into nanoseconds since epoch.

Accepts ISO-8601 local date-time formats: "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss", or "yyyy-MM-ddTHH:mm:ss.f" where the fractional part can be 1-9 digits.

Parameters
strThe timestamp string to parse.
Returns
The number of nanoseconds since epoch, or an error.

◆ ParseTimestampNsWithZone()

Result< int64_t > iceberg::TemporalUtils::ParseTimestampNsWithZone ( std::string_view  str)
static

Parses a timestamp-with-zone string into nanoseconds since epoch (UTC).

Accepts the same formats as ParseTimestampNs, with a timezone suffix: "Z", "+HH:mm", or "-HH:mm". Non-UTC offsets are converted to UTC. The seconds and fractional parts are optional (e.g. "yyyy-MM-ddTHH:mm+00:00").

Parameters
strThe timestamp string to parse.
Returns
The number of nanoseconds since epoch (UTC), or an error.

◆ ParseTimestampWithZone()

Result< int64_t > iceberg::TemporalUtils::ParseTimestampWithZone ( std::string_view  str)
static

Parses a timestamp-with-zone string into microseconds since epoch (UTC).

Accepts the same formats as ParseTimestamp, with a timezone suffix: "Z", "+HH:mm", or "-HH:mm". Non-UTC offsets are converted to UTC. The seconds and fractional parts are optional (e.g. "yyyy-MM-ddTHH:mm+00:00").

Parameters
strThe timestamp string to parse.
Returns
The number of microseconds since epoch (UTC), or an error.

The documentation for this class was generated from the following files: