aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/algol/parc_Time.c
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-02-05 08:50:26 +0100
committerAngelo Mantellini <manangel@cisco.com>2019-02-06 16:23:04 +0100
commit9f68541e0f55495d61dd9e583bec38740a247597 (patch)
tree55519e34159ac1eb691e080e4c1eab5b0e4847bd /libparc/parc/algol/parc_Time.c
parentb77148ddc3def71e6c412c3afb5f1c20be2d77cd (diff)
[HICN-26] Windows compatibilty for libparc
Change-Id: I6ebff82a81a2bf42fa3bf210ff0e6e530ce21915 Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'libparc/parc/algol/parc_Time.c')
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Time.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/libparc/parc/algol/parc_Time.c b/libparc/parc/algol/parc_Time.c
index 07ab185b..8f292c1b 100755..100644
--- a/libparc/parc/algol/parc_Time.c
+++ b/libparc/parc/algol/parc_Time.c
@@ -13,17 +13,16 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+#include <config.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <sys/time.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Time.h>
#include <parc/algol/parc_Memory.h>
@@ -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, &ltime);
+ 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, &ltime);
+ 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);
}