AceTimeClock  1.3.0
Clock classes for Arduino 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 <AceTime.h> // LocalDate
13 #include "Clock.h"
14 
15 namespace ace_time {
16 namespace clock {
17 
21 class UnixClock: public Clock {
22  public:
23  explicit UnixClock() {}
24 
26  void setup() {}
27 
36  acetime_t getNow() const override {
37  return time(nullptr) - Epoch::secondsToCurrentEpochFromUnixEpoch64();
38  }
39 };
40 
41 }
42 }
43 
44 #endif
45 
46 #endif
Abstract base class for objects that provide and store time.
Definition: Clock.h:19
An implementation of Clock that works on Unix using EpoxyDuino.
Definition: UnixClock.h:21
void setup()
Setup function that currently does nothing.
Definition: UnixClock.h:26
acetime_t getNow() const override
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
Definition: UnixClock.h:36