|
nfx-datetime 0.1.1
Cross-platform C++ DateTime library with 100-nanosecond precision and ISO 8601 support
|
Timezone-aware DateTime with UTC offset. More...
#include <nfx/datetime/DateTimeOffset.h>
Public Member Functions | |
| constexpr | DateTimeOffset () noexcept |
| Default constructor (minimum DateTimeOffset value with zero offset). | |
| constexpr | DateTimeOffset (const DateTime &dateTime, const TimeSpan &offset) noexcept |
| Construct from DateTime and offset. | |
| DateTimeOffset (const DateTime &dateTime) noexcept | |
| Construct from DateTime (assumes local timezone offset). | |
| constexpr | DateTimeOffset (std::int64_t ticks, const TimeSpan &offset) noexcept |
| Construct from tick count and offset. | |
| DateTimeOffset (std::int32_t year, std::int32_t month, std::int32_t day, const TimeSpan &offset) noexcept | |
| Construct from date components and offset. | |
| DateTimeOffset (std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour, std::int32_t minute, std::int32_t second, const TimeSpan &offset) noexcept | |
| Construct from date and time components and offset. | |
| DateTimeOffset (std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour, std::int32_t minute, std::int32_t second, std::int32_t millisecond, const TimeSpan &offset) noexcept | |
| Construct from date and time components with milliseconds and offset. | |
| DateTimeOffset (std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour, std::int32_t minute, std::int32_t second, std::int32_t millisecond, std::int32_t microsecond, const TimeSpan &offset) noexcept | |
| Construct from date and time components with microseconds and offset. | |
| DateTimeOffset (std::string_view iso8601String) | |
| Parse from ISO 8601 string with timezone offset. | |
| DateTimeOffset (const DateTimeOffset &)=default | |
| Copy constructor. | |
| DateTimeOffset (DateTimeOffset &&) noexcept=default | |
| Move constructor. | |
| ~DateTimeOffset ()=default | |
| Destructor. | |
| DateTimeOffset & | operator= (const DateTimeOffset &)=default |
| Copy assignment operator. | |
| DateTimeOffset & | operator= (DateTimeOffset &&) noexcept=default |
| Move assignment operator. | |
| constexpr std::strong_ordering | operator<=> (const DateTimeOffset &other) const noexcept |
| Three-way comparison operator (compares UTC values). | |
| constexpr bool | operator== (const DateTimeOffset &other) const noexcept |
| Equality comparison (compares UTC values). | |
| constexpr DateTimeOffset | operator+ (const TimeSpan &duration) const noexcept |
| Add time duration. | |
| constexpr DateTimeOffset | operator- (const TimeSpan &duration) const noexcept |
| Subtract time duration. | |
| constexpr TimeSpan | operator- (const DateTimeOffset &other) const noexcept |
| Get time difference between DateTimeOffsets (in UTC). | |
| constexpr DateTimeOffset & | operator+= (const TimeSpan &duration) noexcept |
| Add time duration (in-place). | |
| constexpr DateTimeOffset & | operator-= (const TimeSpan &duration) noexcept |
| Subtract time duration (in-place). | |
| constexpr const DateTime & | dateTime () const noexcept |
| Get the DateTime component (local time). | |
| constexpr const TimeSpan & | offset () const noexcept |
| Get the offset from UTC. | |
| DateTime | utcDateTime () const noexcept |
| Get UTC DateTime equivalent. | |
| DateTime | localDateTime () const noexcept |
| Get local DateTime equivalent. | |
| constexpr std::int64_t | ticks () const noexcept |
| Get tick count (100-nanosecond units of local time). | |
| constexpr std::int64_t | utcTicks () const noexcept |
| Get UTC tick count. | |
| std::int32_t | year () const noexcept |
| Get year component (1-9999). | |
| std::int32_t | month () const noexcept |
| Get month component (1-12). | |
| std::int32_t | day () const noexcept |
| Get day component (1-31). | |
| std::int32_t | hour () const noexcept |
| Get hour component (0-23). | |
| std::int32_t | minute () const noexcept |
| Get minute component (0-59). | |
| std::int32_t | second () const noexcept |
| Get second component (0-59). | |
| std::int32_t | millisecond () const noexcept |
| Get millisecond component (0-999). | |
| std::int32_t | microsecond () const noexcept |
| Get microsecond component (0-999). | |
| std::int32_t | nanosecond () const noexcept |
| Get nanosecond component (0-900, in hundreds). | |
| std::int32_t | dayOfWeek () const noexcept |
| Get day of week (0=Sunday, 6=Saturday). | |
| std::int32_t | dayOfYear () const noexcept |
| Get day of year (1-366). | |
| std::int32_t | totalOffsetMinutes () const noexcept |
| Get offset in total minutes. | |
| std::int64_t | toEpochSeconds () const noexcept |
| Convert to Epoch timestamp (seconds since epoch). | |
| std::int64_t | toEpochMilliseconds () const noexcept |
| Convert to Epoch timestamp (milliseconds since epoch). | |
| DateTimeOffset | date () const noexcept |
| Get date component (time set to 00:00:00). | |
| TimeSpan | timeOfDay () const noexcept |
| Get time of day as duration since midnight. | |
| DateTimeOffset | toOffset (const TimeSpan &newOffset) const noexcept |
| Convert to specified offset. | |
| DateTimeOffset | toUniversalTime () const noexcept |
| Convert to UTC (offset = 00:00:00). | |
| DateTimeOffset | toLocalTime () const noexcept |
| Convert to local time (system timezone). | |
| std::int64_t | toFILETIME () const noexcept |
| Convert to Windows FILETIME format. | |
| DateTimeOffset | add (const TimeSpan &value) const noexcept |
| Add time span. | |
| DateTimeOffset | addDays (double days) const noexcept |
| Add days. | |
| DateTimeOffset | addHours (double hours) const noexcept |
| Add hours. | |
| DateTimeOffset | addMilliseconds (double milliseconds) const noexcept |
| Add milliseconds. | |
| DateTimeOffset | addMinutes (double minutes) const noexcept |
| Add minutes. | |
| DateTimeOffset | addMonths (std::int32_t months) const noexcept |
| Add months. | |
| DateTimeOffset | addSeconds (double seconds) const noexcept |
| Add seconds. | |
| DateTimeOffset | addTicks (std::int64_t ticks) const noexcept |
| Add ticks. | |
| DateTimeOffset | addYears (std::int32_t years) const noexcept |
| Add years. | |
| TimeSpan | subtract (const DateTimeOffset &value) const noexcept |
| Subtract DateTimeOffset and return TimeSpan. | |
| DateTimeOffset | subtract (const TimeSpan &value) const noexcept |
| Subtract TimeSpan and return DateTimeOffset. | |
| std::string | toString () const |
| Convert to ISO 8601 string with offset. | |
| std::string | toString (DateTime::Format format) const |
| Convert to string using specified format. | |
| std::string | toIso8601Extended () const |
| Convert to ISO 8601 extended format with full precision and offset. | |
| bool | equals (const DateTimeOffset &other) const noexcept |
| Check if this DateTimeOffset equals another (same UTC time). | |
| bool | equalsExact (const DateTimeOffset &other) const noexcept |
| Check if this DateTimeOffset equals another exactly (same local time and offset). | |
| bool | isValid () const noexcept |
| Check if this DateTimeOffset is valid. | |
Static Public Member Functions | |
| static DateTimeOffset | now () noexcept |
| Get current local time with system timezone offset. | |
| static DateTimeOffset | utcNow () noexcept |
| Get current UTC time (offset = 00:00:00). | |
| static DateTimeOffset | today () noexcept |
| Get current local date (time set to 00:00:00). | |
| static DateTimeOffset | min () noexcept |
| Get minimum DateTimeOffset value. | |
| static DateTimeOffset | max () noexcept |
| Get maximum DateTimeOffset value. | |
| static DateTimeOffset | epoch () noexcept |
| Get Unix epoch DateTimeOffset (January 1, 1970 00:00:00 UTC). | |
| static bool | fromString (std::string_view iso8601String, DateTimeOffset &result) noexcept |
| Parse ISO 8601 string with timezone offset safely without throwing exceptions. | |
| static std::optional< DateTimeOffset > | fromString (std::string_view iso8601String) noexcept |
| Parse ISO 8601 string with timezone offset and return optional DateTimeOffset. | |
| static DateTimeOffset | fromEpochSeconds (std::int64_t seconds) noexcept |
| Create from Epoch timestamp seconds with UTC offset. | |
| static DateTimeOffset | fromEpochMilliseconds (std::int64_t milliseconds) noexcept |
| Create from Epoch timestamp milliseconds with UTC offset. | |
| static DateTimeOffset | fromFILETIME (std::int64_t FILETIME) noexcept |
| Create DateTimeOffset from Windows FILETIME format. | |
Timezone-aware DateTime with UTC offset.
Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time (UTC). Composed of a DateTime value and a TimeSpan offset that defines the difference from UTC.
Key features:
Definition at line 167 of file DateTimeOffset.h.
|
inlineconstexprnoexcept |
Construct from DateTime and offset.
| dateTime | The DateTime component (local time) |
| offset | The timezone offset from UTC |

|
explicitnoexcept |
Construct from DateTime (assumes local timezone offset).
| dateTime | The DateTime to use (local timezone offset will be determined automatically) |

|
inlineconstexprnoexcept |
Construct from tick count and offset.
| ticks | Number of 100-nanosecond intervals since January 1, 0001 (local time) |
| offset | The timezone offset from UTC |

|
inlinenoexcept |
Construct from date components and offset.
| year | Year component (1-9999) |
| month | Month component (1-12) |
| day | Day component (1-31) |
| offset | The timezone offset from UTC |

|
inlinenoexcept |
Construct from date and time components and offset.
| year | Year component (1-9999) |
| month | Month component (1-12) |
| day | Day component (1-31) |
| hour | Hour component (0-23) |
| minute | Minute component (0-59) |
| second | Second component (0-59) |
| offset | The timezone offset from UTC |

|
inlinenoexcept |
Construct from date and time components with milliseconds and offset.
| year | Year component (1-9999) |
| month | Month component (1-12) |
| day | Day component (1-31) |
| hour | Hour component (0-23) |
| minute | Minute component (0-59) |
| second | Second component (0-59) |
| millisecond | Millisecond component (0-999) |
| offset | The timezone offset from UTC |

|
inlinenoexcept |
Construct from date and time components with microseconds and offset.
| year | Year component (1-9999) |
| month | Month component (1-12) |
| day | Day component (1-31) |
| hour | Hour component (0-23) |
| minute | Minute component (0-59) |
| second | Second component (0-59) |
| millisecond | Millisecond component (0-999) |
| microsecond | Microsecond component (0-999) |
| offset | The timezone offset from UTC |

|
inlineexplicit |
Parse from ISO 8601 string with timezone offset.
| iso8601String | ISO 8601 formatted string with timezone offset to parse |

|
inlinenodiscardnoexcept |
Add time span.
| value | The TimeSpan to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add days.
| days | The number of days to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add hours.
| hours | The number of hours to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add milliseconds.
| milliseconds | The number of milliseconds to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add minutes.
| minutes | The number of minutes to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add months.
| months | The number of months to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add seconds.
| seconds | The number of seconds to add to this DateTimeOffset |


|
inlinenodiscardnoexcept |
Add ticks.
| ticks | The number of 100-nanosecond ticks to add to this DateTimeOffset |


|
nodiscardnoexcept |
Add years.
| years | The number of years to add to this DateTimeOffset |


|
nodiscardnoexcept |
Get date component (time set to 00:00:00).


|
inlinenodiscardconstexprnoexcept |
Get the DateTime component (local time).


|
inlinenodiscardnoexcept |
Get day component (1-31).


|
inlinenodiscardnoexcept |
Get day of week (0=Sunday, 6=Saturday).


|
inlinenodiscardnoexcept |
Get day of year (1-366).


|
staticnodiscardnoexcept |
Get Unix epoch DateTimeOffset (January 1, 1970 00:00:00 UTC).


|
inlinenodiscardnoexcept |
Check if this DateTimeOffset equals another (same UTC time).
| other | The DateTimeOffset to compare with |


|
inlinenodiscardnoexcept |
Check if this DateTimeOffset equals another exactly (same local time and offset).
| other | The DateTimeOffset to compare with |


|
staticnodiscardnoexcept |
Create from Epoch timestamp milliseconds with UTC offset.
| milliseconds | The number of milliseconds since Unix epoch (January 1, 1970 00:00:00 UTC) |


|
staticnodiscardnoexcept |
Create from Epoch timestamp seconds with UTC offset.
| seconds | The number of seconds since Unix epoch (January 1, 1970 00:00:00 UTC) |


|
staticnodiscardnoexcept |
Create DateTimeOffset from Windows FILETIME format.
Works on any platform - performs mathematical epoch conversion only. Useful for processing Windows-originated data on any system.
| FILETIME | 100-nanosecond intervals since January 1, 1601 UTC |


|
staticnodiscardnoexcept |
Parse ISO 8601 string with timezone offset and return optional DateTimeOffset.
| iso8601String | The ISO 8601 formatted string with timezone offset to parse |

|
staticnodiscardnoexcept |
Parse ISO 8601 string with timezone offset safely without throwing exceptions.
| iso8601String | The ISO 8601 formatted string with timezone offset to parse |
| result | Reference to store the parsed DateTimeOffset if successful |


|
inlinenodiscardnoexcept |
Get hour component (0-23).


|
nodiscardnoexcept |
Check if this DateTimeOffset is valid.


|
nodiscardnoexcept |
Get local DateTime equivalent.


|
staticnodiscardnoexcept |
Get maximum DateTimeOffset value.


|
inlinenodiscardnoexcept |
Get microsecond component (0-999).


|
inlinenodiscardnoexcept |
Get millisecond component (0-999).


|
staticnodiscardnoexcept |
Get minimum DateTimeOffset value.


|
inlinenodiscardnoexcept |
Get minute component (0-59).


|
inlinenodiscardnoexcept |
Get month component (1-12).


|
inlinenodiscardnoexcept |
Get nanosecond component (0-900, in hundreds).


|
staticnodiscardnoexcept |
Get current local time with system timezone offset.


|
inlinenodiscardconstexprnoexcept |
Get the offset from UTC.


|
inlineconstexprnoexcept |
Add time duration.
| duration | The TimeSpan to add to this DateTimeOffset |

|
inlineconstexprnoexcept |
Add time duration (in-place).
| duration | The TimeSpan to add to this DateTimeOffset |

|
inlineconstexprnoexcept |
Get time difference between DateTimeOffsets (in UTC).
| other | The DateTimeOffset to subtract from this DateTimeOffset |

|
inlineconstexprnoexcept |
Subtract time duration.
| duration | The TimeSpan to subtract from this DateTimeOffset |

|
inlineconstexprnoexcept |
Subtract time duration (in-place).
| duration | The TimeSpan to subtract from this DateTimeOffset |

|
inlineconstexprnoexcept |
Three-way comparison operator (compares UTC values).
| other | The DateTimeOffset to compare with |

|
default |
Copy assignment operator.

|
defaultnoexcept |
Move assignment operator.

|
inlineconstexprnoexcept |
Equality comparison (compares UTC values).
| other | The DateTimeOffset to compare with |

|
inlinenodiscardnoexcept |
Get second component (0-59).


|
inlinenodiscardnoexcept |
Subtract DateTimeOffset and return TimeSpan.
| value | The DateTimeOffset to subtract from this DateTimeOffset |


|
inlinenodiscardnoexcept |
Subtract TimeSpan and return DateTimeOffset.
| value | The TimeSpan to subtract from this DateTimeOffset |

|
inlinenodiscardconstexprnoexcept |
Get tick count (100-nanosecond units of local time).


|
inlinenodiscardnoexcept |
Get time of day as duration since midnight.


|
staticnodiscardnoexcept |
Get current local date (time set to 00:00:00).


|
inlinenodiscardnoexcept |
Convert to Epoch timestamp (milliseconds since epoch).


|
inlinenodiscardnoexcept |
Convert to Epoch timestamp (seconds since epoch).


|
nodiscardnoexcept |
Convert to Windows FILETIME format.
Works on any platform - performs mathematical epoch conversion only. Useful for interoperability with Windows-originated data on any system.


|
nodiscard |
Convert to ISO 8601 extended format with full precision and offset.


|
nodiscardnoexcept |
Convert to local time (system timezone).


|
nodiscardnoexcept |
Convert to specified offset.
| newOffset | The new timezone offset to convert to |


|
nodiscard |
Convert to ISO 8601 string with offset.


|
nodiscard |
Convert to string using specified format.
| format | The format to use for string conversion |

|
inlinenodiscardnoexcept |
Get offset in total minutes.


|
nodiscardnoexcept |
Convert to UTC (offset = 00:00:00).


|
nodiscardnoexcept |
Get UTC DateTime equivalent.


|
staticnodiscardnoexcept |
Get current UTC time (offset = 00:00:00).


|
inlinenodiscardconstexprnoexcept |
Get UTC tick count.


|
inlinenodiscardnoexcept |
Get year component (1-9999).

