6 #ifndef ACE_TIME_TIME_OFFSET_H 7 #define ACE_TIME_TIME_OFFSET_H 22 namespace time_offset_mutation {
23 void incrementHour(TimeOffset& offset);
24 void increment15Minutes(TimeOffset& offset);
61 static const int8_t kErrorCode = INT8_MIN;
80 int8_t code = hour * 4 + minute / 15;
97 static TimeOffset forOffsetString(
const char* offsetString);
107 static TimeOffset forOffsetStringChainable(
const char*& offsetString);
129 return (int16_t) 15 * mOffsetCode;
134 return (int32_t) 60 * toMinutes();
143 hour = mOffsetCode / 4;
144 minute = (mOffsetCode % 4) * 15;
152 bool isZero()
const {
return mOffsetCode == 0; }
156 return mOffsetCode == kErrorCode;
160 void printTo(Print& printer)
const;
169 friend void time_offset_mutation::incrementHour(
TimeOffset& offset);
170 friend void time_offset_mutation::increment15Minutes(
TimeOffset& offset);
173 static const uint8_t kTimeOffsetStringLength = 6;
177 mOffsetCode(offsetCode) {}
180 void setOffsetCode(int8_t offsetCode) { mOffsetCode = offsetCode; }
192 int8_t mOffsetCode = 0;
196 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.