Skip to content

Commit

Permalink
fixed case issues on include files
Browse files Browse the repository at this point in the history
	modified:   CMakeLists.txt
	modified:   goveebttemplogger.cpp
	modified:   gvh-organizelogs.cpp
  • Loading branch information
wcbonner committed Feb 1, 2024
1 parent 9cd583e commit b12ed51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 88 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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
)

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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion goveebttemplogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#include <unistd.h> // For close()
#include <utime.h>
#include <vector>
#include "WimISO8601.h"
#include "wimiso8601.h"
#include "att-types.h"
#include "uuid.h"

Expand Down
85 changes: 1 addition & 84 deletions gvh-organizelogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <sys/types.h>
#include <unistd.h> // For close()
#include <utime.h>
#include "wimiso8601.h"

/////////////////////////////////////////////////////////////////////////////
#if __has_include("goveebttemplogger-version.h")
Expand All @@ -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;
Expand Down

0 comments on commit b12ed51

Please sign in to comment.