AceTime  1.7.5
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
HardwareDateTime.cpp
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #include <AceCommon.h>
7 #include "HardwareDateTime.h"
8 #include "../common/DateStrings.h"
9 
10 using ace_common::printPad2To;
11 
12 namespace ace_time {
13 
14 namespace hw {
15 
16 // Print HardwareDateTime in ISO8601 format
17 void HardwareDateTime::printTo(Print& printer) const {
18  // Date
19  printer.print(F("20"));
20  printPad2To(printer, year, '0');
21  printer.print('-');
22  printPad2To(printer, month, '0');
23  printer.print('-');
24  printPad2To(printer, day, '0');
25  printer.print('T');
26 
27  // Time
28  printPad2To(printer, hour, '0');
29  printer.print(':');
30  printPad2To(printer, minute, '0');
31  printer.print(':');
32  printPad2To(printer, second, '0');
33 
34  // Week day
35  printer.print(DateStrings().dayOfWeekLongString(dayOfWeek));
36 }
37 
38 
39 }
40 }
ace_time::DateStrings
Class that translates a numeric month (1-12) or dayOfWeek (1-7) into a human readable string.
Definition: DateStrings.h:26
ace_time::hw::HardwareDateTime::printTo
void printTo(Print &printer) const
Print HardwareDateTime to 'printer'.
Definition: HardwareDateTime.cpp:17