Bi-monthly release with minor bug fixes and improvements
// Get local time epoch in UNIX seconds
time_epoch = mktime(<m);
--- lx200_OnStep.cpp.bak 2022-03-22 09:15:28.455583393 +0900
+++ lx200_OnStep.cpp 2022-03-22 09:15:00.531800080 +0900
@@ -4750,6 +4750,9 @@
struct tm utm;
time_t time_epoch;
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
+
double offset = 0;
if (getUTFOffset(&offset))
{
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
-------------------- drivers/telescope/ioptronHC8406.cpp ---------------------
index 2626278d1..ca37ce08a 100644
@@ -1156,6 +1156,9 @@ bool ioptronHC8406::sendScopeTime()
struct tm ltm;
struct tm utm;
time_t time_epoch;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
if (isSimulation())
{
---------------------- drivers/telescope/lx200_OnStep.cpp ----------------------
index 425d0f6ab..7bd1b4264 100644
@@ -4749,6 +4749,9 @@ bool LX200_OnStep::sendScopeTime()
struct tm ltm;
struct tm utm;
time_t time_epoch;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
double offset = 0;
if (getUTFOffset(&offset))
-------------------- drivers/telescope/lx200_TeenAstro.cpp --------------------
index 548ad1660..325785aab 100644
@@ -888,6 +888,9 @@ bool LX200_TeenAstro::sendScopeTime()
struct tm ltm;
struct tm utm;
time_t time_epoch;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
double offset = 0;
---------------------- drivers/telescope/lx200pulsar2.cpp ----------------------
index ea2c29211..062c7c664 100644
@@ -3362,6 +3362,11 @@ bool LX200Pulsar2::storeScopeLocation()
bool LX200Pulsar2::sendScopeTime()
{
struct tm ltm;
+ struct tm utm;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
+
if (isSimulation())
{
const time_t t = time(nullptr);
@@ -3380,7 +3385,7 @@ bool LX200Pulsar2::sendScopeTime()
// Get time epoch and convert to TimeT
const time_t time_epoch = mktime(<m);
- struct tm utm;
+
localtime_r(&time_epoch, &utm);
// Format it into ISO 8601
--------------------- drivers/telescope/lx200telescope.cpp ---------------------
index 786aeca4c..26b202276 100644
@@ -1315,6 +1315,9 @@ bool LX200Telescope::sendScopeTime()
struct tm ltm;
struct tm utm;
time_t time_epoch;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
double offset = 0;
if (getUTFOffset(&offset))
------------------------ drivers/telescope/rainbow.cpp ------------------------
index 0c68f6b39..2456f88ef 100644
@@ -1516,6 +1516,9 @@ bool Rainbow::sendScopeTime()
struct tm ltm;
struct tm utm;
time_t time_epoch;
+
+ memset(<m, 0, sizeof(ltm));
+ memset(&utm, 0, sizeof(utm));
double offset = 0;
if (getUTFOffset(&offset))
------------------------------- tools/evalINDI.c -------------------------------
index d77395033..730518f27 100644
@@ -507,6 +507,8 @@ static int pstatestr(char *state)
static time_t timestampINDI(char *ts)
{
struct tm tm;
+
+ memset(&tm, 0, sizeof(tm));
if (6 == sscanf(ts, "%d-%d-%dT%d:%d:%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec))
{
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
LOGF_DEBUG("### OnStep ltm.tm_isdst: %i", ltm.tm_isdst);
double offset = 0;
if (getUTFOffset(&offset))
{
char utcStr[8] = {0};
snprintf(utcStr, 8, "%.2f", offset);
IUSaveText(&TimeT[1], utcStr);
}
else
{
LOG_WARN("Could not obtain UTC offset from mount!");
return false;
}
if (getLocalTime(ctime) == false)
{
LOG_WARN("Could not obtain local time from mount!");
return false;
}
if (getLocalDate(cdate) == false)
{
LOG_WARN("Could not obtain local date from mount!");
return false;
}
// To ISO 8601 format in LOCAL TIME!
char datetime[MAXINDINAME] = {0};
snprintf(datetime, MAXINDINAME, "%sT%s", cdate, ctime);
LOGF_DEBUG("### OnStep Local DateTime: %s", datetime);
// Now that date+time are combined, let's get tm representation of it.
if (strptime(datetime, "%FT%T", <m) == nullptr)
{
LOGF_WARN("Could not process mount date and time: %s", datetime);
return false;
}
LOGF_DEBUG("### OnStep after strptime ltm date: %i-%i-%i", ltm.tm_year, ltm.tm_mon, ltm.tm_mday);
LOGF_DEBUG("### OnStep after strptime ltm time: %i:%i:%i", ltm.tm_hour, ltm.tm_min, ltm.tm_sec);
LOGF_DEBUG("### OnStep after strptime ltm.tm_isdst: %i", ltm.tm_isdst);
// Get local time epoch in UNIX seconds
time_epoch = mktime(<m);
LOGF_DEBUG("OnStep Local DateTime time_epoch: %i", time_epoch);
// LOCAL to UTC by subtracting offset.
time_epoch -= static_cast<int>(offset * 3600.0);
LX200 OnStep : "[DEBUG] ### OnStep ltm.tm_isdst: 1074791425 " <<<< wrong value
LX200 OnStep : "[SCOPE] CMD <:GG#> "
LX200 OnStep : "[SCOPE] RES <+09> "
LX200 OnStep : "[SCOPE] VAL [9] "
LX200 OnStep : "[SCOPE] CMD <:GL#> "
LX200 OnStep : "[SCOPE] RES <04:08:07> "
LX200 OnStep : "[SCOPE] VAL [4.13528] "
LX200 OnStep : "[SCOPE] <getCalendarDate> "
LX200 OnStep : "[SCOPE] CMD <:GC#> "
LX200 OnStep : "[SCOPE] RES <03/23/22> "
LX200 OnStep : "[DEBUG] ### OnStep Local DateTime: 2022-03-23T04:08:07 " <<<< OnStep Local
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm date: 122-2-23 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm time: 4:8:7 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm.tm_isdst: 1074791425 " <<<< wrong value
LX200 OnStep : "[DEBUG] OnStep Local DateTime time_epoch: -1 " <<<< Error
LX200 OnStep : "[DEBUG] Mount controller UTC Time: 1970-01-01T17:59:59 " <<<< failed
LX200 OnStep : "[DEBUG] Mount controller UTC Offset: -9.00 "
Setting UTC time from device: "LX200 OnStep" "木 1月 1 17:59:59 1970 GMT" <<<< failed
->>>>>> snprintf(datetime, MAXINDINAME, "%sT%s", cdate, ctime);
LX200 OnStep : "[DEBUG] ### OnStep Local DateTime: 2022-03-23T04:08:07 " <<<< OnStep Local
->>>>>> if (strptime(datetime, "%FT%T", <m) == nullptr)
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm date: 122-2-23 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm time: 4:8:7 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm.tm_isdst: 1074791425 " <<<< wrong value
LX200 OnStep : "[DEBUG] OnStep Local DateTime time_epoch: -1 " <<<< Error
LX200 OnStep : "[DEBUG] ### OnStep ltm.tm_isdst: 0 " <<<< initialized value
LX200 OnStep : "[SCOPE] CMD <:GG#> "
LX200 OnStep : "[SCOPE] RES <+09> "
LX200 OnStep : "[SCOPE] VAL [9] "
LX200 OnStep : "[SCOPE] CMD <:GL#> "
LX200 OnStep : "[SCOPE] RES <04:11:37> "
LX200 OnStep : "[SCOPE] VAL [4.19361] "
LX200 OnStep : "[SCOPE] <getCalendarDate> "
LX200 OnStep : "[SCOPE] CMD <:GC#> "
LX200 OnStep : "[SCOPE] RES <03/23/22> "
LX200 OnStep : "[DEBUG] ### OnStep Local DateTime: 2022-03-23T04:11:37 " <<<< OnStep Local
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm date: 122-2-23 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm time: 4:11:37 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm.tm_isdst: 0 " <<<< initialized value
LX200 OnStep : "[DEBUG] OnStep Local DateTime time_epoch: 1647976297 " <<<< OK
LX200 OnStep : "[DEBUG] Mount controller UTC Time: 2022-03-23T13:11:37 " <<<< OK
LX200 OnStep : "[DEBUG] Mount controller UTC Offset: -9.00 "
Setting UTC time from device: "LX200 OnStep" "水 3月 23 13:11:37 2022 GMT" <<<< OK
->>>>>> snprintf(datetime, MAXINDINAME, "%sT%s", cdate, ctime);
LX200 OnStep : "[DEBUG] ### OnStep Local DateTime: 2022-03-23T04:11:37 " <<<< OnStep Local
->>>>>> if (strptime(datetime, "%FT%T", <m) == nullptr)
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm date: 122-2-23 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm time: 4:11:37 " <<<< OK
LX200 OnStep : "[DEBUG] ### OnStep after strptime ltm.tm_isdst: 0 " <<<< initialized value
LX200 OnStep : "[DEBUG] OnStep Local DateTime time_epoch: 1647976297 " <<<< OK
LX200 OnStep : "[DEBUG] Mount controller UTC Time: 2022-03-23T13:11:37 " <<<< OK
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
RAW ISDST = -1309029128
SEC = 7
MIN = 8
HR = 4
DAY = 23
MON = 2
YR = 122
DWK = 3
DYR = 81
DST = -1309029128
ISDST after strptime = -1309029128
ISDST after clobber >0 1074791425
Got MKTIME = -1
ISDST after clobber =0 = 0
Got MKTIME = 1647976087
ISDST after clobber < 0 -1074791425
Got MKTIME = 1647976087
# timedatectl
Local time: 木 2022-03-24 08:43:06 JST
Universal time: 水 2022-03-23 23:43:06 UTC
RTC time: n/a
Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
# sudo timedatectl set-timezone US/Central
Local time: 水 2022-03-23 18:56:44 CDT
Universal time: 水 2022-03-23 23:56:44 UTC
RTC time: n/a
Time zone: US/Central (CDT, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
RAW ISDST = -1615921928
SEC = 7
MIN = 8
HR = 4
DAY = 23
MON = 2
YR = 122
DWK = 3
DYR = 81
DST = -1615921928
ISDST after strptime = -1615921928
ISDST after clobber >0 1074791425
Got MKTIME = 1648026487
ISDST after clobber =0 = 0
Got MKTIME = 1648030087
ISDST after clobber < 0 -1074791425
Got MKTIME = 1648030087
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.