Merge PR #470 - implement automatic DST toggling

Implements logic to automatically offset daylight saving time settings
when calculating timezone offsets. This should make the DST functions
work automatically with no need for user input in most cases.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/470
This commit is contained in:
Matheus Afonso Martins Moreira
2024-09-08 13:41:52 -03:00
32 changed files with 295 additions and 165 deletions

View File

@@ -45,6 +45,13 @@ typedef struct {
uint32_t days; // 0-4294967295
} watch_duration_t;
typedef enum {
DST_STARTING,
DST_OCCURRING,
DST_ENDING,
DST_ENDED
} dst_t;
/** @brief Returns a two-letter weekday for the given timestamp, suitable for display
* in positions 0-1 of the watch face
* @param date_time The watch_date_time whose weekday you want.
@@ -78,6 +85,17 @@ uint16_t watch_utility_days_since_new_year(uint16_t year, uint8_t month, uint8_t
*/
uint8_t is_leap(uint16_t year);
/** @brief Returns off of dst_t based off if DST is occurring, srted, ended, or none of those.
* @param date_time The watch_date_time that you wish to convert.
* @return DST_OCCURRING, DST_HAPPENING, DST_ENDING, DST_ENDED
*/
uint8_t get_dst_status(watch_date_time date_time);
/** @brief Returns true if it's DST and false otherwise.
* @param date_time The watch_date_time that you wish to convert.
*/
bool dst_occurring(watch_date_time date_time);
/** @brief Returns the UNIX time (seconds since 1970) for a given date/time in UTC.
* @param date_time The watch_date_time that you wish to convert.
* @param year The year of the date you wish to convert.