6 #include "common/util.h" 7 #include "common/DateStrings.h" 12 using common::printPad2;
13 using common::printPad3;
14 using common::DateStrings;
17 const uint8_t LocalDate::sDayOfWeek[12] = {
33 const uint8_t LocalDate::sDaysInMonth[12] = {
50 printer.print(F(
"<Invalid LocalDate>"));
55 printer.print(
year());
57 printPad2(printer, mMonth);
59 printPad2(printer, mDay);
68 if (strlen(dateString) < kDateStringLength) {
75 const char* s = dateString;
78 int16_t
year = (*s++ -
'0');
79 year = 10 * year + (*s++ -
'0');
80 year = 10 * year + (*s++ -
'0');
81 year = 10 * year + (*s++ -
'0');
87 uint8_t
month = (*s++ -
'0');
88 month = 10 * month + (*s++ -
'0');
94 uint8_t
day = (*s++ -
'0');
95 day = 10 * day + (*s++ -
'0');
Class that translates a numeric month (1-12) or dayOfWeek (1-7) into a human readable string...
static LocalDate forError()
Factory method that returns a LocalDate which represents an error condition.
static LocalDate forDateString(const char *dateString)
Factory method.
void printTo(Print &printer) const
Print LocalDate to 'printer' in ISO 8601 format, along with the day of week.
static LocalDate forDateStringChainable(const char *&dateString)
Variant of forDateString() that updates the pointer to the next unprocessed character.
bool isError() const
Return true if any component indicates an error condition.
uint8_t day() const
Return the day of the month.
static LocalDate forComponents(int16_t year, uint8_t month, uint8_t day)
Factory method using separated year, month and day fields.
The date (year, month, day) representing the date without regards to time zone.
const char * dayOfWeekLongString(uint8_t dayOfWeek)
Return the short dayOfWeek name.
uint8_t month() const
Return the month with January=1, December=12.
int16_t year() const
Return the full year instead of just the last 2 digits.
uint8_t dayOfWeek() const
Calculate the day of week given the (year, month, day).