Skip to content

Commit

Permalink
NtpClock.*: rename Epoch::daysToCurrentEpochFromConverterEpoch() to d…
Browse files Browse the repository at this point in the history
…aysToCurrentEpochFromInternalEpoch()
  • Loading branch information
bxparks committed Jun 23, 2023
1 parent fd935f8 commit f21f984
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ace_time/clock/NtpClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ acetime_t NtpClock::readResponse() const {
// NTP epoch is 1900-01-01. Unix epoch is 1970-01-01. GPS epoch is 1980-01-06.
// AceTime v2 epoch is 2050-01-01 by default but is adjustable at runtime.
acetime_t NtpClock::convertNtpSecondsToAceTimeSeconds(uint32_t ntpSeconds) {
// Sometimes the NTP packet is garage and contains 0. Mark that as invalid.
// Sometimes the NTP packet is garbage and contains 0. Mark that as invalid.
// NOTE: Is this necessary? Let's comment it out for now.
//if (ntpSeconds == 0) return kInvalidSeconds;

Expand All @@ -179,8 +179,8 @@ acetime_t NtpClock::convertNtpSecondsToAceTimeSeconds(uint32_t ntpSeconds) {
// 32-bit range of NTP seconds to the 32-bit AceTime seconds, automatically
// accounting for NTP rollovers, for any AceTime currentEpochYear().
int32_t daysToCurrentEpochFromNtpEpoch =
Epoch::daysToCurrentEpochFromConverterEpoch()
+ kDaysToConverterEpochFromNtpEpoch;
Epoch::daysToCurrentEpochFromInternalEpoch()
+ kDaysToInternalEpochFromNtpEpoch;
uint32_t secondsToCurrentEpochFromNtpEpoch = (uint32_t) 86400
* (uint32_t) daysToCurrentEpochFromNtpEpoch;
uint32_t epochSeconds = ntpSeconds - secondsToCurrentEpochFromNtpEpoch;
Expand Down
4 changes: 2 additions & 2 deletions src/ace_time/clock/NtpClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ class NtpClock: public Clock {

/**
* Number of days between NTP epoch (1900-01-01T00:00:00Z) and
* AceTime Epoch Converter epoch (2000-01-01T00:00:00Z).
* AceTime internal epoch (2000-01-01T00:00:00Z).
*/
static const int32_t kDaysToConverterEpochFromNtpEpoch = 36524;
static const int32_t kDaysToInternalEpochFromNtpEpoch = 36524;

/** Send an NTP request to the time server at the given address. */
void sendNtpPacket(const IPAddress& address) const;
Expand Down

0 comments on commit f21f984

Please sign in to comment.