Skip to content

Commit

Permalink
use localtime instead of localtime_r for windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Apr 9, 2024
1 parent 05f0449 commit d42a483
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugins/src/tascarmod_systime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class tascar_systime_t : public TASCAR::module_base_t {
double* p_sec;
struct timeval tv;
struct timezone tz;
struct tm caltime;
};

tascar_systime_t::tascar_systime_t(const TASCAR::module_cfg_t& cfg)
Expand Down Expand Up @@ -74,13 +73,13 @@ tascar_systime_t::~tascar_systime_t()
void tascar_systime_t::update(uint32_t, bool)
{
gettimeofday(&tv, &tz);
localtime_r(&(tv.tv_sec), &caltime);
*p_year = caltime.tm_year;
*p_month = caltime.tm_mon;
*p_day = caltime.tm_mday;
*p_hour = caltime.tm_hour;
*p_min = caltime.tm_min;
*p_sec = caltime.tm_sec;
struct tm* caltime = localtime(&(tv.tv_sec));
*p_year = caltime->tm_year;
*p_month = caltime->tm_mon;
*p_day = caltime->tm_mday;
*p_hour = caltime->tm_hour;
*p_min = caltime->tm_min;
*p_sec = caltime->tm_sec;
*p_sec += 0.000001 * tv.tv_usec;
session->dispatch_data_message(path.c_str(), msg);
}
Expand Down

0 comments on commit d42a483

Please sign in to comment.