AceTime  0.5.1
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 #if defined(ARDUINO)
7 
8 #include "HardwareDateTime.h"
9 #include "../common/util.h"
10 #include "../common/DateStrings.h"
11 
12 namespace ace_time {
13 
14 using common::printPad2;
15 using common::DateStrings;
16 
17 namespace hw {
18 
19 // Print HardwareDateTime in ISO8601 format
20 void HardwareDateTime::printTo(Print& printer) const {
21  // Date
22  printer.print(F("20"));
23  printPad2(printer, year);
24  printer.print('-');
25  printPad2(printer, month);
26  printer.print('-');
27  printPad2(printer, day);
28  printer.print('T');
29 
30  // Time
31  printPad2(printer, hour);
32  printer.print(':');
33  printPad2(printer, minute);
34  printer.print(':');
35  printPad2(printer, second);
36 
37  // Week day
38  printer.print(DateStrings().dayOfWeekLongString(dayOfWeek));
39 }
40 
41 
42 }
43 }
44 
45 #endif