diff --git a/Readme.md b/Readme.md index 7556e0d..86add2c 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/Time.cpp b/Time.cpp index bd3cc7b..fd07a57 100644 --- a/Time.cpp +++ b/Time.cpp @@ -33,6 +33,7 @@ #include #endif +#define TIMELIB_ENABLE_MILLIS #include "TimeLib.h" static tmElements_t tm; // a cache of time elements diff --git a/TimeLib.h b/TimeLib.h index 75ff482..38cfa2c 100644 --- a/TimeLib.h +++ b/TimeLib.h @@ -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) @@ -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);