aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-04-02 01:12:52 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-04-02 01:12:52 +0100
commitdd425c8ef8952d3a8553029dbbc7d89abd0908df (patch)
tree00be553a6ae8b5228ce8b84d6c56dfab40baba41 /src
parent2a2b4e8e041c8f795f519b93f6b4a0a2b87a7359 (diff)
downloadverteco-dd425c8ef8952d3a8553029dbbc7d89abd0908df.tar.gz
modbuslog: use time.h functions to manipulate datev1.5
Fixes issue that became apparent after switch to DST
Diffstat (limited to '')
-rw-r--r--src/modbuslog.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/modbuslog.c b/src/modbuslog.c
index 43d102d..d967e4a 100644
--- a/src/modbuslog.c
+++ b/src/modbuslog.c
@@ -156,7 +156,9 @@ int main(int argc, char *argv[]) {
select(0, NULL, NULL, NULL, NULL);
time_t t = time(NULL);
- time_t unixtime_min = (((int) t) / 60 * 60);
+ struct tm unixtime_min_time_t = *gmtime (&t);
+ unixtime_min_time_t.tm_sec = 0;
+ time_t unixtime_min = mktime(&unixtime_min_time_t);
//int unixtime = (int) t;
//printf("%d\n", unixtime);
@@ -281,9 +283,12 @@ int main(int argc, char *argv[]) {
//MODBUS_SET_INT16_TO_INT8(tab_int8, index, value);
// round forward to next midnight
- time_t unixtime_day = ((((int) t) / 86400 * 86400) + 86400);
-
- struct tm midnight = *localtime(&unixtime_day);
+ struct tm midnight = *localtime(&t);
+ midnight.tm_hour = 0;
+ midnight.tm_min = 0;
+ midnight.tm_sec = 0;
+ midnight.tm_mday += 1;
+ mktime (&midnight);
char log_filename[50];