AceTimeClock  1.3.0
Clock classes for Arduino 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 <AceTime.h>
8 #include "HardwareDateTime.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 }
uint8_t year
[00, 99], year - 2000
uint8_t dayOfWeek
[1, 7], interpretation undefined, increments every day
void printTo(Print &printer) const
Print HardwareDateTime to 'printer'.