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