Feature/refactor datetime os dependency (#63)

* remove dependency on OS for time functions.

* add datetime epoch to and from seconds (yikes! 64-bit!). Add symmetric midnight seconds for unit test. Add unit tests.

* clean up BACnet date time warnings

* fix BACnet datetime warnings

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2020-04-04 11:23:26 -05:00
committed by GitHub
parent b159402647
commit 0ce6368b43
7 changed files with 142 additions and 108 deletions
+3 -24
View File
@@ -30,7 +30,6 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h> /* for memcpy */
#include <time.h>
#include "bacnet/bacdef.h"
#include "bacnet/bacdcode.h"
#include "bacnet/datetime.h"
@@ -260,29 +259,9 @@ bool Load_Control_Object_Name(
static void Update_Current_Time(BACNET_DATE_TIME *bdatetime)
{
time_t timer;
struct tm *tblock;
/*
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
*/
timer = time(NULL);
tblock = localtime(&timer);
datetime_set_values(bdatetime, (uint16_t)tblock->tm_year,
(uint8_t)tblock->tm_mon, (uint8_t)tblock->tm_mday,
(uint8_t)tblock->tm_hour, (uint8_t)tblock->tm_min,
(uint8_t)tblock->tm_sec, 0);
if (bdatetime) {
datetime_local(&bdatetime->date, &bdatetime->time, NULL, NULL);
}
}
/* convert the shed level request into an Analog Output Present_Value */