1 #ifndef ACE_TIME_TIME_OFFSET_H 2 #define ACE_TIME_TIME_OFFSET_H 17 namespace time_offset_mutation {
18 void incrementHour(TimeOffset& offset);
19 void increment15Minutes(TimeOffset& offset);
70 int8_t uhour = (hour < 0) ? -hour : hour;
71 uint8_t code = uhour * 4 + minute / 15;
87 static TimeOffset forOffsetString(
const char* offsetString);
109 bool isZero()
const {
return mOffsetCode == 0; }
116 return (int16_t) 15 * mOffsetCode;
121 return (int32_t) 60 * toMinutes();
126 uint8_t code = (mOffsetCode < 0) ? -mOffsetCode : mOffsetCode;
128 hour = (mOffsetCode < 0) ? -hour : hour;
129 minute = (code & 0x03) * 15;
134 return mOffsetCode == kErrorCode;
138 void printTo(Print& printer)
const;
149 friend class TimeOffsetMutator;
151 friend void time_offset_mutation::incrementHour(
TimeOffset& offset);
152 friend void time_offset_mutation::increment15Minutes(
TimeOffset& offset);
155 static const int8_t kErrorCode = -128;
158 static const uint8_t kTimeOffsetStringLength = 6;
167 static TimeOffset forOffsetStringChainable(
const char*& offsetString);
171 mOffsetCode(offsetCode) {}
174 void setOffsetCode(int8_t offsetCode) { mOffsetCode = offsetCode; }
186 int8_t mOffsetCode = 0;
190 return a.mOffsetCode == b.mOffsetCode;
static TimeOffset forError()
Return an error indicator.
int8_t toOffsetCode() const
Return the time offset as the number of 15 minute increments.
void toHourMinute(int8_t &hour, uint8_t &minute) const
Extract hour and minute representation of the offset.
bool isError() const
Return true if this TimeOffset represents an error.
static TimeOffset forHour(int8_t hour)
Create TimeOffset with the corresponding hour offset.
An implementation of ZoneSpecifier which allows the user to manually adjust the UTC offset and the DS...
static TimeOffset forHourMinute(int8_t hour, uint8_t minute)
Create TimeOffset from (hour, minute) offset, where the sign of hour determines the sign of the offse...
static TimeOffset forOffsetCode(int8_t offsetCode)
Create TimeOffset from the offset code.
int16_t toMinutes() const
Return the time offset as minutes.
The date (year, month, day) and time (hour, minute, second) fields representing the time with an offs...
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC...
static TimeOffset forMinutes(int16_t minutes)
Create TimeOffset from minutes from 00:00.
Class that describes a time zone.
int32_t toSeconds() const
Return the time offset as seconds.
bool isZero() const
Returns true if offset is 00:00.
An implementation of ZoneSpecifier that supports a subset of the zones containing in the TZ Database...