From 095acdf041c7acf041e8482c35d6dbbe3610d31d Mon Sep 17 00:00:00 2001 From: KOEGlike Date: Tue, 26 Dec 2023 11:37:39 +0100 Subject: [PATCH 1/3] added default values to TimeElements --- TimeLib.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TimeLib.h b/TimeLib.h index b587046..fea7d8a 100644 --- a/TimeLib.h +++ b/TimeLib.h @@ -43,13 +43,13 @@ typedef enum { } tmByteFields; typedef struct { - uint8_t Second; - uint8_t Minute; - uint8_t Hour; - uint8_t Wday; // day of week, sunday is day 1 - uint8_t Day; - uint8_t Month; - uint8_t Year; // offset from 1970; + uint8_t Second=0; + uint8_t Minute=0; + uint8_t Hour=0; + uint8_t Wday=1; // day of week, sunday is day 1 + uint8_t Day=0; + uint8_t Month=0; + uint8_t Year=0; // offset from 1970; } tmElements_t, TimeElements, *tmElementsPtr_t; //convenience macros to convert to and from tm years From 56f7514094fb5e2f4b9f04482728dc7d9269057e Mon Sep 17 00:00:00 2001 From: KOEGlike Date: Tue, 2 Jan 2024 12:15:18 +0100 Subject: [PATCH 2/3] hello --- Time.cpp | 12 ++++++++++-- TimeLib.h | 14 +++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Time.cpp b/Time.cpp index 0dcb29f..ec4883a 100644 --- a/Time.cpp +++ b/Time.cpp @@ -208,14 +208,16 @@ time_t makeTime(const tmElements_t &tm){ int i; uint32_t seconds; - + // Serial.println("start"); // seconds from 1970 till 1 jan 00:00:00 of the given year seconds= tm.Year*(SECS_PER_DAY * 365); + // Serial.println(seconds); for (i = 0; i < tm.Year; i++) { if (LEAP_YEAR(i)) { seconds += SECS_PER_DAY; // add extra days for leap years } } + // Serial.println(seconds); // add days for this year, months start from 1 for (i = 1; i < tm.Month; i++) { @@ -225,10 +227,16 @@ time_t makeTime(const tmElements_t &tm){ seconds += SECS_PER_DAY * monthDays[i-1]; //monthDay array starts from 0 } } - seconds+= (tm.Day-1) * SECS_PER_DAY; + // Serial.println(seconds); + seconds+= (tm.Day!=0?(tm.Day-1):0) * SECS_PER_DAY; + // Serial.println(seconds); seconds+= tm.Hour * SECS_PER_HOUR; + // Serial.println(seconds); seconds+= tm.Minute * SECS_PER_MIN; + // Serial.println(seconds); seconds+= tm.Second; + // Serial.println(seconds); + // Serial.println("end"); return (time_t)seconds; } /*=====================================================*/ diff --git a/TimeLib.h b/TimeLib.h index fea7d8a..b587046 100644 --- a/TimeLib.h +++ b/TimeLib.h @@ -43,13 +43,13 @@ typedef enum { } tmByteFields; typedef struct { - uint8_t Second=0; - uint8_t Minute=0; - uint8_t Hour=0; - uint8_t Wday=1; // day of week, sunday is day 1 - uint8_t Day=0; - uint8_t Month=0; - uint8_t Year=0; // offset from 1970; + uint8_t Second; + uint8_t Minute; + uint8_t Hour; + uint8_t Wday; // day of week, sunday is day 1 + uint8_t Day; + uint8_t Month; + uint8_t Year; // offset from 1970; } tmElements_t, TimeElements, *tmElementsPtr_t; //convenience macros to convert to and from tm years From b6a91eff2d7ce685a45492f025905d0c14645fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Marcell?= Date: Sat, 17 Aug 2024 00:01:44 +0300 Subject: [PATCH 3/3] Create CMakeLists.txt --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d2b3329 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.24) +idf_component_register( + SRCS "Time.cpp" # Add all source files here + INCLUDE_DIRS "./" + REQUIRES "arduino" # Add include directories here +) \ No newline at end of file