2 #include "common/util.h" 3 #include "common/DateStrings.h" 4 #include "TimeOffset.h" 8 using common::printPad2;
15 printer.print((hour < 0) ?
'-' :
'+');
19 common::printPad2(printer, hour);
21 common::printPad2(printer, minute);
26 if (strlen(offsetString) != kTimeOffsetStringLength) {
30 return forOffsetStringChainable(offsetString);
33 TimeOffset TimeOffset::forOffsetStringChainable(
const char*& offsetString) {
34 const char* s = offsetString;
38 if (utcSign !=
'-' && utcSign !=
'+') {
43 uint8_t hour = (*s++ -
'0');
44 hour = 10 * hour + (*s++ -
'0');
48 uint8_t minute = (*s++ -
'0');
49 minute = 10 * minute + (*s++ -
'0');
static TimeOffset forError()
Return an error indicator.
void toHourMinute(int8_t &hour, uint8_t &minute) const
Extract hour and minute representation of the offset.
static TimeOffset forOffsetString(const char *offsetString)
Create from an offset string ("-07:00" or "+01:00").
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...
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC...
void printTo(Print &printer) const
Print the human readable string.