1 #include "common/util.h" 2 #include "common/DateStrings.h" 7 using common::printPad2;
8 using common::printPad3;
9 using common::DateStrings;
12 const uint8_t LocalDate::sDayOfWeek[12] = {
28 const uint8_t LocalDate::sDaysInMonth[12] = {
45 printer.print(F(
"<Invalid LocalDate>"));
50 printer.print(
year());
52 printPad2(printer, mMonth);
54 printPad2(printer, mDay);
59 printer.print(ds.weekDayLongString(
dayOfWeek()));
63 if (strlen(dateString) < kDateStringLength) {
66 return forDateStringChainable(dateString);
69 LocalDate LocalDate::forDateStringChainable(
const char*& dateString) {
70 const char* s = dateString;
73 int16_t
year = (*s++ -
'0');
74 year = 10 * year + (*s++ -
'0');
75 year = 10 * year + (*s++ -
'0');
76 year = 10 * year + (*s++ -
'0');
83 uint8_t
month = (*s++ -
'0');
84 month = 10 * month + (*s++ -
'0');
90 uint8_t
day = (*s++ -
'0');
91 day = 10 * day + (*s++ -
'0');
static LocalDate forError()
Factory method that returns a LocalDate which represents an error condition.
LocalDate()
Default constructor does nothing.
static LocalDate forDateString(const char *dateString)
Factory method.
uint8_t month() const
Return the month with January=1, December=12.
bool isError() const
Return true if any component indicates an error condition.
void printTo(Print &printer) const
Print LocalDate to 'printer' in ISO 8601 format, along with the day of week.
int16_t year() const
Return the full year instead of just the last 2 digits.
uint8_t day() const
Return the day of the month.
The date (year, month, day) representing the date without regards to time zone.
static const int16_t kEpochYear
Base year of epoch.
uint8_t dayOfWeek() const
Calculate the day of week given the (year, month, day).
int8_t yearTiny() const
Return the single-byte year offset from year 2000.