Skip to content

Using getFormattedTime() to format a given time #30

Closed as not planned
@sheffieldnikki

Description

@sheffieldnikki

I've adjusted getFormattedTime() to take an (optional) 'secs' argument, so that the same formatting code can be used to format any given time, while still formatting the NTP time if the argument is left out. This is similar to time conversion functions in other languages, and might avoid the need to include a dedicated time/date library in some projects.

NTPClient.h:

/**
 * @return secs argument (or 0 for current time) formatted like `hh:mm:ss`
 */
String getFormattedTime(unsigned long secs = 0);

NTPClient.cpp:

String NTPClient::getFormattedTime(unsigned long secs) {
  unsigned long rawTime = secs ? secs : this->getEpochTime();

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions