mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-15 11:26:36 +02:00
AK: Move nanoseconds_within_second to Duration
This commit is contained in:
committed by
Nico Weber
parent
98c74df103
commit
edd85b1281
@@ -238,6 +238,12 @@ public:
|
||||
// Rounds towards -inf (it was the easiest to implement).
|
||||
[[nodiscard]] timeval to_timeval() const;
|
||||
|
||||
[[nodiscard]] constexpr i64 nanoseconds_within_second() const
|
||||
{
|
||||
VERIFY(m_nanoseconds < 1'000'000'000);
|
||||
return m_nanoseconds;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool is_zero() const { return (m_seconds == 0) && (m_nanoseconds == 0); }
|
||||
[[nodiscard]] bool is_negative() const { return m_seconds < 0; }
|
||||
|
||||
@@ -489,7 +495,7 @@ public:
|
||||
[[nodiscard]] i64 nanoseconds() const { return m_offset.to_nanoseconds(); }
|
||||
// Never returns a point in the future, since fractional seconds are cut off.
|
||||
[[nodiscard]] i64 truncated_seconds() const { return m_offset.to_truncated_seconds(); }
|
||||
[[nodiscard]] i64 nanoseconds_within_second() const { return to_timespec().tv_nsec; }
|
||||
[[nodiscard]] i64 nanoseconds_within_second() const { return m_offset.nanoseconds_within_second(); }
|
||||
|
||||
constexpr bool operator==(MonotonicTime const& other) const { return this->m_offset == other.m_offset; }
|
||||
constexpr int operator<=>(MonotonicTime const& other) const { return this->m_offset <=> other.m_offset; }
|
||||
|
||||
Reference in New Issue
Block a user