AceTime  1.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.
Public Member Functions | Static Public Attributes | List of all members
ace_time::clock::Clock Class Referenceabstract

Base class for objects that provide and store time. More...

#include <Clock.h>

Inheritance diagram for ace_time::clock::Clock:
Inheritance graph
[legend]

Public Member Functions

virtual ~Clock ()
 Virtual destructor. More...
 
virtual acetime_t getNow () const =0
 Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z). More...
 
virtual void sendRequest () const
 Send a time request asynchronously. More...
 
virtual bool isResponseReady () const
 Return true if a response is ready. More...
 
virtual acetime_t readResponse () const
 Returns number of seconds since AceTime epoch (2000-01-01). More...
 
virtual void setNow (acetime_t)
 Set the time to the indicated seconds. More...
 

Static Public Attributes

static const acetime_t kInvalidSeconds = LocalTime::kInvalidSeconds
 

Detailed Description

Base class for objects that provide and store time.

For example, a DS3231 RTC chip, an NTP client, or a GPS module.

Definition at line 20 of file Clock.h.

Constructor & Destructor Documentation

◆ ~Clock()

virtual ace_time::clock::Clock::~Clock ( )
inlinevirtual

Virtual destructor.

Unused except in unit tests.

Definition at line 25 of file Clock.h.

Member Function Documentation

◆ getNow()

virtual acetime_t ace_time::clock::Clock::getNow ( ) const
pure virtual

Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).

Returns kInvalidSeconds if an error has occured.

This is a blocking call. Some clocks (e.g. NTP client) this may take many seconds. On those clocks, use the asynchronous methods (sendRequest(), isResponseReady(), and readResponse()) instead.

Implemented in ace_time::clock::NtpClock, ace_time::clock::SystemClock, and ace_time::clock::DS3231Clock.

◆ isResponseReady()

virtual bool ace_time::clock::Clock::isResponseReady ( ) const
inlinevirtual

Return true if a response is ready.

Reimplemented in ace_time::clock::NtpClock.

Definition at line 41 of file Clock.h.

◆ readResponse()

virtual acetime_t ace_time::clock::Clock::readResponse ( ) const
inlinevirtual

Returns number of seconds since AceTime epoch (2000-01-01).

Return kInvalidSeconds if there is an error. Valid only if isResponseReady() returns true.

Reimplemented in ace_time::clock::NtpClock.

Definition at line 48 of file Clock.h.

◆ sendRequest()

virtual void ace_time::clock::Clock::sendRequest ( ) const
inlinevirtual

Send a time request asynchronously.

Reimplemented in ace_time::clock::NtpClock.

Definition at line 38 of file Clock.h.

◆ setNow()

virtual void ace_time::clock::Clock::setNow ( acetime_t  )
inlinevirtual

Set the time to the indicated seconds.

Calling with a value of kInvalidSeconds indicates an error condition, so the method should do nothing. Some clocks do not support this feature, for example, NTP or GPS clocks and this method will be a no-op.

Reimplemented in ace_time::clock::SystemClock, and ace_time::clock::DS3231Clock.

Definition at line 56 of file Clock.h.


The documentation for this class was generated from the following file: