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.
OffsetDateTime.cpp
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #include "common/util.h"
7 #include "common/DateStrings.h"
8 #include "LocalDateTime.h"
9 #include "OffsetDateTime.h"
10 
11 namespace ace_time {
12 
13 using common::printPad2;
14 using common::DateStrings;
15 
16 void OffsetDateTime::printTo(Print& printer) const {
17  if (isError()) {
18  printer.print(F("<Invalid OffsetDateTime>"));
19  return;
20  }
21 
22  // LocalDateTime
23  mLocalDateTime.printTo(printer);
24 
25  // TimeOffset "+/-hh:mm
26  mTimeOffset.printTo(printer);
27 }
28 
30  if (strlen(dateString) < kDateStringLength) {
31  return forError();
32  }
33  return forDateStringChainable(dateString);
34 }
35 
37  const char* s = dateString;
38 
41 
42  dateString = s;
43  return OffsetDateTime(ldt, offset);
44 }
45 
46 }
void printTo(Print &printer) const
Print LocalDateTime to &#39;printer&#39; in ISO 8601 format.
static TimeOffset forOffsetStringChainable(const char *&offsetString)
Variant of forOffsetString() that updates the string pointer to the next unprocessed character...
Definition: TimeOffset.cpp:41
static LocalDateTime forDateStringChainable(const char *&dateString)
Variant of forDateString() that updates the pointer to the next unprocessed character.
void printTo(Print &printer) const
Print OffsetDateTime to &#39;printer&#39; in ISO 8601 format.
void printTo(Print &printer) const
Print the human readable string.
Definition: TimeOffset.cpp:15
OffsetDateTime()
Constructor.
The date (year, month, day), time (hour, minute, second) and offset from UTC (timeOffset).
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC...
Definition: TimeOffset.h:58
static OffsetDateTime forDateStringChainable(const char *&dateString)
Variant of forDateString() that updates the pointer to the next unprocessed character.
bool isError() const
Return true if any component indicates an error condition.
static OffsetDateTime forError()
Factory method that returns an instance whose isError() is true.
Class that holds the date-time as the components (year, month, day, hour, minute, second) without reg...
Definition: LocalDateTime.h:27
static OffsetDateTime forDateString(const char *dateString)
Factory method.