Updated time code changes to compile with Visual Studio Express 2008.
This commit is contained in:
@@ -497,7 +497,11 @@ char *Device_Valid_Object_Id(
|
|||||||
static void Update_Current_Time(void)
|
static void Update_Current_Time(void)
|
||||||
{
|
{
|
||||||
struct tm *tblock = NULL;
|
struct tm *tblock = NULL;
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
time_t tTemp;
|
||||||
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
struct tm
|
struct tm
|
||||||
|
|
||||||
@@ -511,21 +515,36 @@ int tm_wday Day of week [0,6] (Sunday =0).
|
|||||||
int tm_yday Day of year [0,365].
|
int tm_yday Day of year [0,365].
|
||||||
int tm_isdst Daylight Savings flag.
|
int tm_isdst Daylight Savings flag.
|
||||||
*/
|
*/
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
time(&tTemp);
|
||||||
|
tblock = localtime(&tTemp);
|
||||||
|
#else
|
||||||
if (gettimeofday(&tv, NULL) == 0) {
|
if (gettimeofday(&tv, NULL) == 0) {
|
||||||
tblock = localtime(&tv.tv_sec);
|
tblock = localtime(&tv.tv_sec);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tblock) {
|
if (tblock) {
|
||||||
datetime_set_date(
|
datetime_set_date(
|
||||||
&Local_Date,
|
&Local_Date,
|
||||||
(uint16_t) tblock->tm_year+1900,
|
(uint16_t) tblock->tm_year+1900,
|
||||||
(uint8_t) tblock->tm_mon+1,
|
(uint8_t) tblock->tm_mon+1,
|
||||||
(uint8_t) tblock->tm_mday);
|
(uint8_t) tblock->tm_mday);
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
datetime_set_time(
|
datetime_set_time(
|
||||||
&Local_Time,
|
&Local_Time,
|
||||||
(uint8_t) tblock->tm_hour,
|
(uint8_t) tblock->tm_hour,
|
||||||
(uint8_t) tblock->tm_min,
|
(uint8_t) tblock->tm_min,
|
||||||
(uint8_t) tblock->tm_sec,
|
(uint8_t) tblock->tm_sec,
|
||||||
(uint8_t)(tv.tv_usec / 10000));
|
(uint8_t)(tv.tv_usec / 10000));
|
||||||
|
#else
|
||||||
|
datetime_set_time(
|
||||||
|
&Local_Time,
|
||||||
|
(uint8_t) tblock->tm_hour,
|
||||||
|
(uint8_t) tblock->tm_min,
|
||||||
|
(uint8_t) tblock->tm_sec,
|
||||||
|
0);
|
||||||
|
#endif
|
||||||
if (tblock->tm_isdst) {
|
if (tblock->tm_isdst) {
|
||||||
Daylight_Savings_Status = true;
|
Daylight_Savings_Status = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,8 +33,10 @@
|
|||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define _timeb timeb
|
#define _timeb timeb
|
||||||
|
|||||||
Reference in New Issue
Block a user