AceTime  0.6
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.
Clock.h
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_CLOCK_H
7 #define ACE_TIME_CLOCK_H
8 
9 #include <stdint.h>
10 #include "../common/common.h"
11 #include "../LocalTime.h"
12 
13 namespace ace_time {
14 namespace clock {
15 
20 class Clock {
21  public:
22  static const acetime_t kInvalidSeconds = LocalTime::kInvalidSeconds;
23 
25  virtual ~Clock() {}
26 
35  virtual acetime_t getNow() const = 0;
36 
38  virtual void sendRequest() const {}
39 
41  virtual bool isResponseReady() const { return true; }
42 
48  virtual acetime_t readResponse() const { return getNow(); }
49 
56  virtual void setNow(acetime_t /*epochSeconds*/) {}
57 };
58 
59 }
60 }
61 
62 #endif
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
Definition: LocalTime.h:29
virtual bool isResponseReady() const
Return true if a response is ready.
Definition: Clock.h:41
virtual void setNow(acetime_t)
Set the time to the indicated seconds.
Definition: Clock.h:56
virtual void sendRequest() const
Send a time request asynchronously.
Definition: Clock.h:38
virtual ~Clock()
Virtual destructor.
Definition: Clock.h:25
Base class for objects that provide and store time.
Definition: Clock.h:20
virtual acetime_t readResponse() const
Returns number of seconds since AceTime epoch (2000-01-01).
Definition: Clock.h:48
virtual acetime_t getNow() const =0
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).