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);
56 static const int8_t kErrorCode = INT8_MIN;
75 int8_t code = hour * 4 + minute / 15;
92 static TimeOffset forOffsetString(
const char* offsetString);
102 static TimeOffset forOffsetStringChainable(
const char*& offsetString);
124 return (int16_t) 15 * mOffsetCode;
129 return (int32_t) 60 * toMinutes();
138 hour = mOffsetCode / 4;
139 minute = (mOffsetCode % 4) * 15;
147 bool isZero()
const {
return mOffsetCode == 0; }
151 return mOffsetCode == kErrorCode;
155 void printTo(Print& printer)
const;
164 friend void time_offset_mutation::incrementHour(
TimeOffset& offset);
165 friend void time_offset_mutation::increment15Minutes(
TimeOffset& offset);
168 static const uint8_t kTimeOffsetStringLength = 6;
172 mOffsetCode(offsetCode) {}
175 void setOffsetCode(int8_t offsetCode) { mOffsetCode = offsetCode; }
187 int8_t mOffsetCode = 0;
191 return a.mOffsetCode == b.mOffsetCode;
static TimeOffset forError()
Return an error indicator.
bool isError() const
Return true if this TimeOffset represents an error.
int32_t toSeconds() const
Return the time offset as seconds.
static TimeOffset forHour(int8_t hour)
Create TimeOffset with the corresponding hour offset.
int16_t toMinutes() const
Return the time offset as minutes.
static TimeOffset forOffsetCode(int8_t offsetCode)
Create TimeOffset from the offset code.
static TimeOffset forHourMinute(int8_t hour, int8_t minute)
Create TimeOffset from (hour, minute) offset.
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.
bool isZero() const
Returns true if offset is 00:00.
int8_t toOffsetCode() const
Return the time offset as the number of 15 minute increments.
void toHourMinute(int8_t &hour, int8_t &minute) const
Extract hour and minute representation of the offset.