From 9f68541e0f55495d61dd9e583bec38740a247597 Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Tue, 5 Feb 2019 08:50:26 +0100 Subject: [HICN-26] Windows compatibilty for libparc Change-Id: I6ebff82a81a2bf42fa3bf210ff0e6e530ce21915 Signed-off-by: Angelo Mantellini --- libparc/parc/algol/parc_Time.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) mode change 100755 => 100644 libparc/parc/algol/parc_Time.c (limited to 'libparc/parc/algol/parc_Time.c') diff --git a/libparc/parc/algol/parc_Time.c b/libparc/parc/algol/parc_Time.c old mode 100755 new mode 100644 index 07ab185b..8f292c1b --- a/libparc/parc/algol/parc_Time.c +++ b/libparc/parc/algol/parc_Time.c @@ -13,17 +13,16 @@ * limitations under the License. */ -/** - */ -#include +#ifndef _WIN32 +#include +#endif +#include #include #include #include -#include #include - #include #include @@ -43,11 +42,20 @@ char * parcTime_TimevalAsRFC3339(const struct timeval *utcTime, char result[64]) { char tmbuf[64]; + struct tm *nowtm; + +#ifndef _WIN32 + struct tm theTime; + nowtm = gmtime_r(&utcTime->tv_sec, &theTime); +#else struct tm theTime; + __int64 ltime = utcTime->tv_sec; + int x = _gmtime64_s(&theTime, <ime); + nowtm = &theTime; +#endif - struct tm *nowtm = gmtime_r(&utcTime->tv_sec, &theTime); strftime(tmbuf, sizeof tmbuf, "%Y-%m-%dT%H:%M:%S", nowtm); - snprintf(result, 64, "%s.%06ldZ", tmbuf, (long) utcTime->tv_usec); + snprintf(result, 64, "%s.%06ldZ", tmbuf, (long)utcTime->tv_usec); return result; } @@ -57,7 +65,16 @@ parcTime_TimevalAsISO8601(const struct timeval *utcTime, char result[64]) char tmbuf[64]; struct tm theTime; - struct tm *nowtm = gmtime_r(&utcTime->tv_sec, &theTime); + struct tm *nowtm; + +#ifndef _WIN32 + nowtm = gmtime_r(&utcTime->tv_sec, &theTime); +#else + __int64 ltime = utcTime->tv_sec; + _gmtime64_s(&theTime, <ime); + nowtm = &theTime; +#endif + strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm); snprintf(result, 64, "%s.%06ldZ", tmbuf, (long) utcTime->tv_usec); return result; @@ -66,7 +83,7 @@ parcTime_TimevalAsISO8601(const struct timeval *utcTime, char result[64]) char * parcTime_TimeAsRFC3339(const time_t utcTime, char result[64]) { - struct timeval theTime = { utcTime, 0 }; + struct timeval theTime = { (long)utcTime, 0 }; return parcTime_TimevalAsRFC3339(&theTime, result); } @@ -83,7 +100,7 @@ parcTime_NowAsRFC3339(char result[64]) char * parcTime_TimeAsISO8601(const time_t utcTime, char result[64]) { - struct timeval theTime = { utcTime, 0 }; + struct timeval theTime = { (long)utcTime, 0 }; return parcTime_TimevalAsISO8601(&theTime, result); } -- cgit 1.2.3-korg