AceTime 2.4.0 Date and time classes for Arduino that support timezones from the TZ Database.

TimePeriod.cpp
1 /*
2 * MIT License
3 * Copyright (c) 2018 Brian T. Park
4 */
5
6 #include <Print.h>
7 #include <AceCommon.h>
8 #include "TimePeriod.h"
9
10 using ace_common::printPad2To;
11
12 namespace ace_time {
13
14 void TimePeriod::printTo(Print& printer) const {
15 if (isError()) {
16 const __FlashStringHelper* message;
17 if (mSign == 1) {
18 message = F("<+Inf>");
19 } else if (mSign == -1) {
20 message = F("<-Inf>");
21 } else {
22 message = F("<Error>");
23 }
24 printer.print(message);
25 return;
26 }
27
28 if (mSign < 0) {
29 printer.print('-');
30 }
31 printPad2To(printer, mHour, '0');
32 printer.print(':');
33 printPad2To(printer, mMinute, '0');
34 printer.print(':');
35 printPad2To(printer, mSecond, '0');
36 }
37
38 }
ace_time::TimePeriod::printTo
void printTo(Print &printer) const
Print to given printer.
Definition: TimePeriod.cpp:14
ace_time::TimePeriod::isError
bool isError() const
Return true if this represents an error.
Definition: TimePeriod.h:153