From 0723137212c000288c964ccfd4f0f5eed7911e5e Mon Sep 17 00:00:00 2001 From: pieterbl <30773488+pieterbl@users.noreply.github.com> Date: Mon, 10 Feb 2020 08:21:26 +0100 Subject: [PATCH 1/5] Update Readme.md Update Readme.md - minor text alignment --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index ee44912..4ed4e05 100644 --- a/Readme.md +++ b/Readme.md @@ -148,7 +148,7 @@ Low level functions to convert between system time and individual time elements ```c breakTime(time, &tm); // break time_t into elements stored in tm struct -makeTime(&tm); // return time_t from elements stored in tm struct +makeTime(&tm); // return time_t from elements stored in tm struct ``` The DS1307RTC library included in the download provides an example of how a time provider From d788757ea29a79e4f03968a1cfd04e2d0cf39044 Mon Sep 17 00:00:00 2001 From: pieterbl <30773488+pieterbl@users.noreply.github.com> Date: Mon, 10 Feb 2020 08:26:26 +0100 Subject: [PATCH 2/5] Update Readme.md Update Readme.md - put code-quotes around some types/identifiers --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 4ed4e05..db399fd 100644 --- a/Readme.md +++ b/Readme.md @@ -66,8 +66,8 @@ timeNeedsSync // the time had been set but a sync attempt did timeSet // the time is set and is synced ``` -Time and Date values are not valid if the status is timeNotSet. Otherwise, values can be used but -the returned time may have drifted if the status is timeNeedsSync. +Time and Date values are not valid if the status is `timeNotSet`. Otherwise, values can be used but +the returned time may have drifted if the status is `timeNeedsSync`. ```c setSyncProvider(getTimeFunction); // set the external time provider @@ -140,8 +140,8 @@ See the sketches in the examples directory for usage. The default interval for re-syncing the time is 5 minutes but can be changed by calling the `setSyncInterval(interval)` method to set the number of seconds between re-sync attempts. -The Time library defines a structure for holding time elements that is a compact version of the C tm structure. -All the members of the Arduino tm structure are bytes and the year is offset from 1970. +The Time library defines a structure for holding time elements that is a compact version of the C `tm` structure. +All the members of the Arduino `tm` structure are bytes and the year is offset from 1970. Convenience macros provide conversion to and from the Arduino format. Low level functions to convert between system time and individual time elements are provided: From 286d443e01d05c2e233e763426996152956efc87 Mon Sep 17 00:00:00 2001 From: pieterbl <30773488+pieterbl@users.noreply.github.com> Date: Mon, 10 Feb 2020 08:28:16 +0100 Subject: [PATCH 3/5] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index db399fd..52126c7 100644 --- a/Readme.md +++ b/Readme.md @@ -144,7 +144,7 @@ The Time library defines a structure for holding time elements that is a compact All the members of the Arduino `tm` structure are bytes and the year is offset from 1970. Convenience macros provide conversion to and from the Arduino format. -Low level functions to convert between system time and individual time elements are provided: +Low-level functions to convert between system time and individual time elements are provided: ```c breakTime(time, &tm); // break time_t into elements stored in tm struct From 7acd24427ad55e815319ba11a274ff8a6521a1eb Mon Sep 17 00:00:00 2001 From: pieterbl Date: Mon, 10 Feb 2020 19:33:18 +0100 Subject: [PATCH 4/5] Several punctuation fixes, add pointer to DS1307RTC lib. The current (old) description claimded that the DS1307RTC library is part of the download bundle, which is not (no longer?) the case. Instead pointing to following now: https://github.com/PaulStoffregen/DS1307RTC Change-Id: I28b0c71398e56d50de0c786e4dee97d28f408481 --- Readme.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index 52126c7..10a32a0 100644 --- a/Readme.md +++ b/Readme.md @@ -89,15 +89,15 @@ illustrating how the library can be used with various time sources: A companion Processing sketch will automatically provide these messages if it is running and connected to the Arduino serial port. -- `TimeSerialDateStrings.pde` adds day and month name strings to the sketch above +- `TimeSerialDateStrings.pde` adds day and month name strings to the sketch above. Short (3 characters) and long strings are available to print the days of the week and names of the months. - `TimeRTC` uses a DS1307 real-time clock to provide time synchronization. - A basic RTC library named DS1307RTC is included in the download. - To run this sketch the DS1307RTC library must be installed. + The basic [DS1307RTC library][1] must be downloaded and installed, + in order to run this sketch. -- `TimeRTCSet` is similar to the above and adds the ability to set the Real Time Clock +- `TimeRTCSet` is similar to the above and adds the ability to set the Real Time Clock. - `TimeRTCLog` demonstrates how to calculate the difference between times. It is a very simple logger application that monitors events on digital pins @@ -106,11 +106,11 @@ illustrating how the library can be used with various time sources: - `TimeNTP` uses the Arduino Ethernet shield to access time using the internet NTP time service. The NTP protocol uses UDP and the UdpBytewise library is required, see: - http://bitbucket.org/bjoern/arduino_osc/src/14667490521f/libraries/Ethernet/ + -- `TimeGPS` gets time from a GPS +- `TimeGPS` gets time from a GPS. This requires the TinyGPS library from Mikal Hart: - http://arduiniana.org/libraries/TinyGPS + ## Differences @@ -126,7 +126,7 @@ Changes in the Time library API: - function added to automatically sync time with external source - `localTime` and `maketime` parameters changed, `localTime` renamed to `breakTime` -## Technical notes: +## Technical Notes Internal system time is based on the standard Unix `time_t`. The value is the number of seconds since Jan 1, 1970. @@ -151,5 +151,7 @@ breakTime(time, &tm); // break time_t into elements stored in tm struct makeTime(&tm); // return time_t from elements stored in tm struct ``` -The DS1307RTC library included in the download provides an example of how a time provider +This [DS1307RTC library][1] provides an example of how a time provider can use the low-level functions to interface with the Time library. + +[1]: From 3d5114d04b37bf53c40c6d6157179c05fc88255f Mon Sep 17 00:00:00 2001 From: pieterbl Date: Tue, 11 Feb 2020 23:09:38 +0100 Subject: [PATCH 5/5] Fixed typos in TimeLib.h and Time.cpp Change-Id: Ia05c370e8f09b75dddf11cf2aa8b5de4c21bd45d --- Time.cpp | 6 +++--- TimeLib.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Time.cpp b/Time.cpp index 8e53e56..0dcb29f 100644 --- a/Time.cpp +++ b/Time.cpp @@ -141,9 +141,9 @@ int year(time_t t) { // the year for the given time /*============================================================================*/ /* functions to convert to and from system time */ -/* These are for interfacing with time serivces and are not normally needed in a sketch */ +/* These are for interfacing with time services and are not normally needed in a sketch */ -// leap year calulator expects year argument as years offset from 1970 +// leap year calculator expects year argument as years offset from 1970 #define LEAP_YEAR(Y) ( ((1970+(Y))>0) && !((1970+(Y))%4) && ( ((1970+(Y))%100) || !((1970+(Y))%400) ) ) static const uint8_t monthDays[]={31,28,31,30,31,30,31,31,30,31,30,31}; // API starts months from 1, this array starts from 0 @@ -213,7 +213,7 @@ time_t makeTime(const tmElements_t &tm){ seconds= tm.Year*(SECS_PER_DAY * 365); for (i = 0; i < tm.Year; i++) { if (LEAP_YEAR(i)) { - seconds += SECS_PER_DAY; // add extra days for leap years + seconds += SECS_PER_DAY; // add extra days for leap years } } diff --git a/TimeLib.h b/TimeLib.h index 20e2445..b587046 100644 --- a/TimeLib.h +++ b/TimeLib.h @@ -80,7 +80,7 @@ typedef time_t(*getExternalTime)(); #define elapsedDays(_time_) ((_time_) / SECS_PER_DAY) // this is number of days since Jan 1 1970 #define elapsedSecsToday(_time_) ((_time_) % SECS_PER_DAY) // the number of seconds since last midnight // The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971 -// Always set the correct time before settting alarms +// Always set the correct time before setting alarms #define previousMidnight(_time_) (((_time_) / SECS_PER_DAY) * SECS_PER_DAY) // time at the start of the given day #define nextMidnight(_time_) (previousMidnight(_time_) + SECS_PER_DAY) // time at the end of the given day #define elapsedSecsThisWeek(_time_) (elapsedSecsToday(_time_) + ((dayOfWeek(_time_)-1) * SECS_PER_DAY)) // note that week starts on day 1