MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::calendars::TimeZone Struct Reference

#include <zoned.hpp>

Collaboration diagram for mtcore::calendars::TimeZone:

Classes

struct  OffsetHMS
 

Public Member Functions

constexpr i64 offset_in_nanoseconds () const
 
constexpr i32 offset_in_seconds () const
 
constexpr f64 offset_in_minutes () const
 
constexpr f64 offset_in_hours () const
 
constexpr auto offset () const
 
constexpr Result< void, TimeValidationErrortry_validate () const
 
constexpr auto operator<=> (const TimeZone &tz) const
 

Public Attributes

struct mtcore::calendars::TimeZone::OffsetHMS offsetVal = {}
 
Optional< Slice< const char > > name = nullopt
 

Detailed Description

Definition at line 26 of file zoned.hpp.

Member Function Documentation

◆ offset()

auto mtcore::calendars::TimeZone::offset ( ) const
inlinenodiscardconstexpr

Definition at line 54 of file zoned.hpp.

54{ return offsetVal; }
struct mtcore::calendars::TimeZone::OffsetHMS offsetVal

◆ offset_in_hours()

f64 mtcore::calendars::TimeZone::offset_in_hours ( ) const
inlinenodiscardconstexpr

Definition at line 52 of file zoned.hpp.

52{ return offset_in_minutes() / 60.; }
constexpr f64 offset_in_minutes() const
Definition zoned.hpp:50
Here is the call graph for this function:

◆ offset_in_minutes()

f64 mtcore::calendars::TimeZone::offset_in_minutes ( ) const
inlinenodiscardconstexpr

Definition at line 50 of file zoned.hpp.

50{ return static_cast<f64>(offset_in_seconds()) / 60.; }
double f64
Alias for 64-bit floats.
constexpr i32 offset_in_seconds() const
Definition zoned.hpp:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ offset_in_nanoseconds()

i64 mtcore::calendars::TimeZone::offset_in_nanoseconds ( ) const
inlinenodiscardconstexpr

Definition at line 34 of file zoned.hpp.

34 {
35 const auto secs = offset_in_seconds();
36 return static_cast<i64>(secs) * NANOS_PER_SECOND;
37 }
constexpr i32 NANOS_PER_SECOND
Number of nanoseconds per second.
int64_t i64
Alias for 64-bit ints.
Here is the call graph for this function:

◆ offset_in_seconds()

i32 mtcore::calendars::TimeZone::offset_in_seconds ( ) const
inlinenodiscardconstexpr

Definition at line 39 of file zoned.hpp.

39 {
40 const auto sign = (offsetVal.hours >= 0) ? 1 : -1;
41 auto total = static_cast<i32>(offsetVal.hours);
42 total *= 60;
43 total += offsetVal.minutes;
44 total *= 60;
45 total += offsetVal.seconds;
46 total *= sign;
47 return total;
48 }
constexpr int sign(const T &v)
Gets the sign (1 for positive, -1 for negative, 0 for zero)
int32_t i32
Alias for 32-bit ints.
Here is the caller graph for this function:

◆ operator<=>()

auto mtcore::calendars::TimeZone::operator<=> ( const TimeZone & tz) const
inlinenodiscardconstexpr

Definition at line 72 of file zoned.hpp.

72 {
73 if (const auto c = (offsetVal.hours <=> tz.offsetVal.hours); c != std::strong_ordering::equivalent) {
74 return c;
75 }
76 if (const auto c = (offsetVal.minutes <=> tz.offsetVal.minutes); c != std::strong_ordering::equivalent) {
77 return c;
78 }
79 if (const auto c = (offsetVal.seconds <=> tz.offsetVal.seconds); c != std::strong_ordering::equivalent) {
80 return c;
81 }
82 return std::strong_ordering::equivalent;
83 }

◆ try_validate()

Result< void, TimeValidationError > mtcore::calendars::TimeZone::try_validate ( ) const
inlinenodiscardconstexpr

Definition at line 56 of file zoned.hpp.

56 {
57 if (offsetVal.seconds >= 60) {
59 }
60 if (offsetVal.minutes >= 60) {
62 }
63 if (offsetVal.hours >= 24) {
65 }
66 if (offsetVal.hours <= -24) {
68 }
69 return success();
70 }
Success< void > success()
Creates a successful void Result object.
Definition result.hpp:398
Error< Underlying > error(Underlying err)
Creates an error.
Definition result.hpp:425
Here is the call graph for this function:

Member Data Documentation

◆ name

Optional<Slice<const char> > mtcore::calendars::TimeZone::name = nullopt

Definition at line 32 of file zoned.hpp.

◆ offsetVal

struct mtcore::calendars::TimeZone::OffsetHMS mtcore::calendars::TimeZone::offsetVal = {}

The documentation for this struct was generated from the following file: