Skip to content

Commit

Permalink
Require user to request access to millisecond
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmyatt committed Feb 28, 2018
1 parent 586cddc commit 1b57d09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ year(t); // the year for the given time t
There are also two functions that return the number of milliseconds left-over. Care
should be taken when using this value since there are no functions to set the time
with sub-second accuracy and the value may jump when the time is synchronized.
However, it is always consistent with the current time.
However, it is always consistent with the current time. To access these functions,
you have to `#define TIMELIB_ENABLE_MILLIS` in your sketch.
```c
time_t t = now(uint32_t& m) // store the current time in time variable t and milliseconds in m
Expand Down
1 change: 1 addition & 0 deletions Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <WProgram.h>
#endif

#define TIMELIB_ENABLE_MILLIS
#include "TimeLib.h"

static tmElements_t tm; // a cache of time elements
Expand Down
4 changes: 4 additions & 0 deletions TimeLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ int minute(); // the minute now
int minute(time_t t); // the minute for the given time
int second(); // the second now
int second(time_t t); // the second for the given time
#ifdef TIMELIB_ENABLE_MILLIS
int millisecond(); // the millisecond now
#endif
int day(); // the day now
int day(time_t t); // the day for the given time
int weekday(); // the weekday now (Sunday is day 1)
Expand All @@ -119,7 +121,9 @@ int year(); // the full four digit year: (2009, 2010 etc)
int year(time_t t); // the year for the given time

time_t now(); // return the current time as seconds since Jan 1 1970
#ifdef TIMELIB_ENABLE_MILLIS
time_t now(uint32_t& sysTimeMillis); // return the current time as seconds and milliseconds since Jan 1 1970
#endif
void setTime(time_t t);
void setTime(int hr,int min,int sec,int day, int month, int yr);
void adjustTime(long adjustment);
Expand Down

0 comments on commit 1b57d09

Please sign in to comment.