AceTime  1.7.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.
UnixClock.h
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_UNIX_CLOCK_H
7 #define ACE_TIME_UNIX_CLOCK_H
8 
9 #if defined(EPOXY_DUINO)
10 
11 #include <time.h> // time()
12 #include "Clock.h"
13 #include "../LocalDate.h"
14 
15 namespace ace_time {
16 namespace clock {
17 
21 class UnixClock: public Clock {
22  public:
23  explicit UnixClock() {}
24 
25  void setup() {}
26 
27  acetime_t getNow() const override {
28  return time(nullptr) - LocalDate::kSecondsSinceUnixEpoch;
29  }
30 };
31 
32 }
33 }
34 
35 #endif
36 
37 #endif
ace_time::LocalDate::kSecondsSinceUnixEpoch
static const acetime_t kSecondsSinceUnixEpoch
Number of seconds from Unix epoch (1970-01-01 00:00:00Z) to the AceTime epoch (2000-01-01 00:00:00Z).
Definition: LocalDate.h:69
ace_time::clock::UnixClock
An implementation of Clock that works on Unix using EpoxyDuino.
Definition: UnixClock.h:21
ace_time::clock::Clock
Abstract base class for objects that provide and store time.
Definition: Clock.h:20
ace_time::clock::UnixClock::getNow
acetime_t getNow() const override
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
Definition: UnixClock.h:27