9 #ifndef CPPCOMMON_TIME_TIMEZONE_H
10 #define CPPCOMMON_TIME_TIMEZONE_H
47 {
return timezone1.total() == timezone2.total(); }
49 {
return timezone1.total() != timezone2.total(); }
51 {
return timezone1.total() > timezone2.total(); }
53 {
return timezone1.total() < timezone2.total(); }
55 {
return timezone1.total() >= timezone2.total(); }
57 {
return timezone1.total() <= timezone2.total(); }
60 const std::string&
name() const noexcept {
return _name; }
static Timespan zero() noexcept
Get zero timespan.
Timezone(Timezone &&)=default
Timespan _dstoffset
Timezone daylight saving time offset.
void swap(Timezone &timezone) noexcept
Swap two instances.
Timezone(const Timezone &)=default
static Timezone utc()
Get the UTC timezone (Greenwich Mean Time)
std::string _name
Timezone name.
const std::string & name() const noexcept
Get timezone name.
static Timezone local()
Get the local timezone.
Timezone & operator=(Timezone &&)=default
friend bool operator==(const Timezone &timezone1, const Timezone &timezone2) noexcept
friend bool operator>=(const Timezone &timezone1, const Timezone &timezone2) noexcept
const Timespan & daylight() const noexcept
Get timezone daylight saving time offset.
Timezone()
Initialize timezone with a current local timezone.
UtcTime Convert(const LocalTime &localtime) const
Convert local time to UTC time using the current timezone.
friend bool operator<=(const Timezone &timezone1, const Timezone &timezone2) noexcept
Timespan _offset
Timezone offset.
Timezone & operator=(const Timezone &)=default
Timezone(const std::string &name, const Timespan &offset, const Timespan &dstoffset=Timespan::zero())
Initialize timezone with a given local time offset and daylight saving time offset.
friend bool operator<(const Timezone &timezone1, const Timezone &timezone2) noexcept
friend bool operator>(const Timezone &timezone1, const Timezone &timezone2) noexcept
friend bool operator!=(const Timezone &timezone1, const Timezone &timezone2) noexcept
LocalTime Convert(const UtcTime &utctime) const
Convert UTC time to local time using the current timezone.
const Timespan & offset() const noexcept
Get timezone offset.
Timespan total() const noexcept
Get timezone total offset.
C++ Common project definitions.
Timezone inline implementation.