From b12ed51122759f7f92814142dcca9b595ca148b5 Mon Sep 17 00:00:00 2001 From: William C Bonner Date: Thu, 1 Feb 2024 13:47:47 -0800 Subject: [PATCH] fixed case issues on include files modified: CMakeLists.txt modified: goveebttemplogger.cpp modified: gvh-organizelogs.cpp --- CMakeLists.txt | 6 +-- goveebttemplogger.cpp | 2 +- gvh-organizelogs.cpp | 85 +------------------------------------------ 3 files changed, 5 insertions(+), 88 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f60be8..9161c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if (CMAKE_VERSION VERSION_GREATER 3.22) endif() project (GoveeBTTempLogger - VERSION 2.20240131.0 + VERSION 2.20240201.0 DESCRIPTION "Listen and log Govee Thermometer Bluetooth Low Energy Advertisments" HOMEPAGE_URL https://github.com/wcbonner/GoveeBTTempLogger ) @@ -50,7 +50,7 @@ project (GoveeBTTempLogger configure_file(goveebttemplogger-version.h.in goveebttemplogger-version.h) # Add source to this project's executable. -add_executable (goveebttemplogger goveebttemplogger.cpp goveebttemplogger-version.h att-types.h uuid.c uuid.h WimISO8601.cpp WimISO8601.h) +add_executable (goveebttemplogger goveebttemplogger.cpp goveebttemplogger-version.h att-types.h uuid.c uuid.h wimiso8601.cpp wimiso8601.h) target_link_libraries(goveebttemplogger -lbluetooth -lstdc++fs) if (CMAKE_VERSION VERSION_GREATER 3.12) @@ -70,7 +70,7 @@ if(EXISTS "/etc/rpi-issue") ) endif() -add_executable(gvh-organizelogs gvh-organizelogs.cpp goveebttemplogger-version.h) +add_executable(gvh-organizelogs gvh-organizelogs.cpp goveebttemplogger-version.h wimiso8601.cpp wimiso8601.h) target_link_libraries(gvh-organizelogs -lbluetooth -lstdc++fs) if (CMAKE_VERSION VERSION_GREATER 3.12) diff --git a/goveebttemplogger.cpp b/goveebttemplogger.cpp index 4c1a8f7..d94e74b 100644 --- a/goveebttemplogger.cpp +++ b/goveebttemplogger.cpp @@ -89,7 +89,7 @@ #include // For close() #include #include -#include "WimISO8601.h" +#include "wimiso8601.h" #include "att-types.h" #include "uuid.h" diff --git a/gvh-organizelogs.cpp b/gvh-organizelogs.cpp index 8954ba4..68225c9 100644 --- a/gvh-organizelogs.cpp +++ b/gvh-organizelogs.cpp @@ -52,6 +52,7 @@ #include #include // For close() #include +#include "wimiso8601.h" ///////////////////////////////////////////////////////////////////////////// #if __has_include("goveebttemplogger-version.h") @@ -65,90 +66,6 @@ static const std::string ProgramVersionString("GoveeBTTempLogOrganizer Version " std::filesystem::path LogDirectory; std::filesystem::path BackupDirectory; ///////////////////////////////////////////////////////////////////////////// -std::string timeToISO8601(const time_t& TheTime, const bool LocalTime = false) -{ - std::ostringstream ISOTime; - struct tm UTC; - struct tm* timecallresult(nullptr); - if (LocalTime) - timecallresult = localtime_r(&TheTime, &UTC); - else - timecallresult = gmtime_r(&TheTime, &UTC); - if (nullptr != timecallresult) - { - ISOTime.fill('0'); - if (!((UTC.tm_year == 70) && (UTC.tm_mon == 0) && (UTC.tm_mday == 1))) - { - ISOTime << UTC.tm_year + 1900 << "-"; - ISOTime.width(2); - ISOTime << UTC.tm_mon + 1 << "-"; - ISOTime.width(2); - ISOTime << UTC.tm_mday << "T"; - } - ISOTime.width(2); - ISOTime << UTC.tm_hour << ":"; - ISOTime.width(2); - ISOTime << UTC.tm_min << ":"; - ISOTime.width(2); - ISOTime << UTC.tm_sec; - } - return(ISOTime.str()); -} -std::string getTimeISO8601(const bool LocalTime = false) -{ - time_t timer; - time(&timer); - std::string isostring(timeToISO8601(timer, LocalTime)); - std::string rval; - rval.assign(isostring.begin(), isostring.end()); - return(rval); -} -time_t ISO8601totime(const std::string& ISOTime) -{ - time_t timer(0); - if (ISOTime.length() >= 19) - { - struct tm UTC; - UTC.tm_year = stoi(ISOTime.substr(0, 4)) - 1900; - UTC.tm_mon = stoi(ISOTime.substr(5, 2)) - 1; - UTC.tm_mday = stoi(ISOTime.substr(8, 2)); - UTC.tm_hour = stoi(ISOTime.substr(11, 2)); - UTC.tm_min = stoi(ISOTime.substr(14, 2)); - UTC.tm_sec = stoi(ISOTime.substr(17, 2)); - UTC.tm_gmtoff = 0; - UTC.tm_isdst = -1; - UTC.tm_zone = 0; -#ifdef _MSC_VER - _tzset(); - _get_daylight(&(UTC.tm_isdst)); -#endif -#ifdef __USE_MISC - timer = timegm(&UTC); - if (timer == -1) - return(0); // if timegm() returned an error value, leave time set at epoch -#else - timer = mktime(&UTC); - if (timer == -1) - return(0); // if mktime() returned an error value, leave time set at epoch - timer -= timezone; // HACK: Works in my initial testing on the raspberry pi, but it's currently not DST -#endif -#ifdef _MSC_VER - long Timezone_seconds = 0; - _get_timezone(&Timezone_seconds); - timer -= Timezone_seconds; - int DST_hours = 0; - _get_daylight(&DST_hours); - long DST_seconds = 0; - _get_dstbias(&DST_seconds); - timer += DST_hours * DST_seconds; -#endif - } - return(timer); -} -// Microsoft Excel doesn't recognize ISO8601 format dates with the "T" seperating the date and time -// This function puts a space where the T goes for ISO8601. The dates can be decoded with ISO8601totime() -std::string timeToExcelDate(const time_t& TheTime, const bool LocalTime = false) { std::string ExcelDate(timeToISO8601(TheTime, LocalTime)); ExcelDate.replace(10, 1, " "); return(ExcelDate); } -std::string timeToExcelLocal(const time_t& TheTime) { return(timeToExcelDate(TheTime, true)); }///////////////////////////////////////////////////////////////////////////// bool ValidateDirectory(std::string& DirectoryName) { bool rval = false;