|
| constexpr | TimeSpan (std::int64_t ticks=0) noexcept |
| | Construct from ticks (100-nanosecond units).
|
| constexpr | TimeSpan (std::chrono::system_clock::duration duration) noexcept |
| | Construct from std::chrono duration.
|
| | TimeSpan (std::string_view iso8601String) |
| | Parse from ISO 8601 string.
|
|
| TimeSpan (const TimeSpan &)=default |
| | Copy constructor.
|
|
| TimeSpan (TimeSpan &&) noexcept=default |
| | Move constructor.
|
|
| ~TimeSpan ()=default |
| | Destructor.
|
| TimeSpan & | operator= (const TimeSpan &)=default |
| | Copy assignment operator.
|
| TimeSpan & | operator= (TimeSpan &&) noexcept=default |
| | Move assignment operator.
|
| constexpr std::strong_ordering | operator<=> (const TimeSpan &other) const noexcept |
| | Three-way comparison operator.
|
| constexpr bool | operator== (const TimeSpan &other) const noexcept |
| | Equality comparison.
|
| constexpr TimeSpan | operator+ (const TimeSpan &other) const noexcept |
| | Add time durations.
|
| constexpr TimeSpan | operator- (const TimeSpan &other) const noexcept |
| | Subtract time durations.
|
| constexpr TimeSpan | operator- () const noexcept |
| | Negate time duration.
|
| constexpr TimeSpan & | operator+= (const TimeSpan &other) noexcept |
| | Add time duration (in-place).
|
| constexpr TimeSpan & | operator-= (const TimeSpan &other) noexcept |
| | Subtract time duration (in-place).
|
| TimeSpan | operator* (double multiplier) const noexcept |
| | Multiply time duration by a scalar value.
|
| TimeSpan | operator/ (double divisor) const noexcept |
| | Divide time duration by a scalar value.
|
| double | operator/ (const TimeSpan &other) const noexcept |
| | Divide time duration by another TimeSpan.
|
| double | days () const noexcept |
| | Get total days.
|
| double | hours () const noexcept |
| | Get total hours.
|
| double | minutes () const noexcept |
| | Get total minutes.
|
| double | seconds () const noexcept |
| | Get total seconds.
|
| double | milliseconds () const noexcept |
| | Get total milliseconds.
|
| double | microseconds () const noexcept |
| | Get total microseconds.
|
| double | nanoseconds () const noexcept |
| | Get total nanoseconds.
|
| constexpr std::int64_t | ticks () const noexcept |
| | Get tick count.
|
| std::string | toString () const |
| | Convert to ISO 8601 duration string.
|
| std::chrono::system_clock::duration | toChrono () const noexcept |
| | Convert to std::chrono::system_clock::duration.
|
|
| static bool | fromString (std::string_view iso8601DurationString, TimeSpan &result) noexcept |
| | Parse a TimeSpan from a string safely without throwing exceptions.
|
| static std::optional< TimeSpan > | fromString (std::string_view iso8601DurationString) noexcept |
| | Parse ISO 8601 duration string and return optional TimeSpan.
|
| static TimeSpan | fromChrono (const std::chrono::system_clock::duration &duration) noexcept |
| | Create TimeSpan from std::chrono::system_clock::duration.
|
| static constexpr TimeSpan | fromDays (double days) noexcept |
| | Create a TimeSpan from a number of days.
|
| static constexpr TimeSpan | fromHours (double hours) noexcept |
| | Create a TimeSpan from a number of hours.
|
| static constexpr TimeSpan | fromMinutes (double minutes) noexcept |
| | Create a TimeSpan from a number of minutes.
|
| static constexpr TimeSpan | fromSeconds (double seconds) noexcept |
| | Create a TimeSpan from a number of seconds.
|
| static constexpr TimeSpan | fromMilliseconds (double milliseconds) noexcept |
| | Create a TimeSpan from a number of milliseconds.
|
| static constexpr TimeSpan | fromMicroseconds (double microseconds) noexcept |
| | Create a TimeSpan from a number of microseconds.
|
| static constexpr TimeSpan | fromTicks (double ticks) noexcept |
| | Create a TimeSpan from a number of ticks (100-nanosecond units).
|
Represents a time interval in 100-nanosecond ticks.
Provides high-precision time duration representation and arithmetic operations. Compatible with ISO 8601 duration format for parsing and formatting operations.
Key features:
- 100-nanosecond tick precision for maximum accuracy
- Range: ±10,675,199 days (approximately ±29,247 years)
- Arithmetic operations (addition, subtraction, comparison)
- ISO 8601 duration parsing and formatting (P[n]Y[n]M[n]DT[n]H[n]M[n]S)
- Factory methods for common time units (days, hours, minutes, seconds)
- Conversion methods to various time units with fractional support
This class represents a duration or elapsed time interval, not a specific point in time. For absolute time values, use DateTime or DateTimeOffset.
- Note
- TimeSpan is designed for duration calculations and should not be used to represent calendar dates or clock times. Use DateTime or DateTimeOffset instead.
Definition at line 135 of file TimeSpan.h.