fix: The SBI time string converting error in 32bit
This commit is contained in:
parent
a0ebf20c88
commit
e531ccab5a
|
@ -53,6 +53,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
|
|
|
@ -345,7 +345,7 @@ bool ogs_sbi_time_from_string(ogs_time_t *timestamp, char *str)
|
|||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
ogs_strptime(seconds, "%Y-%m-%dT%H:%M:%S%z", &tm);
|
||||
usecs = (ogs_time_t)(atof(subsecs) * 1000000);
|
||||
usecs = (ogs_time_t)floor(atof(subsecs) * 1000000.0 + 0.5);
|
||||
|
||||
rv = ogs_time_from_gmt(timestamp, &tm, usecs);
|
||||
if (rv != OGS_OK) {
|
||||
|
|
|
@ -42,6 +42,7 @@ libsbi_inc = include_directories('.')
|
|||
|
||||
sbi_cc_flags = ['-DOGS_SBI_COMPILATION']
|
||||
|
||||
libm_dep = cc.find_library('m', required : true)
|
||||
libgnutls_dep = cc.find_library('gnutls', required : true)
|
||||
libnghttp2_dep = dependency('libnghttp2', version: '>=1.18.1')
|
||||
libmicrohttpd_dep = dependency('libmicrohttpd', version: '>=0.9.40')
|
||||
|
@ -56,6 +57,7 @@ libsbi = library('ogssbi',
|
|||
libcrypt_dep,
|
||||
libapp_dep,
|
||||
libsbi_openapi_dep,
|
||||
libm_dep,
|
||||
libgnutls_dep,
|
||||
libnghttp2_dep,
|
||||
libmicrohttpd_dep,
|
||||
|
@ -70,6 +72,7 @@ libsbi_dep = declare_dependency(
|
|||
libcrypt_dep,
|
||||
libapp_dep,
|
||||
libsbi_openapi_dep,
|
||||
libm_dep,
|
||||
libgnutls_dep,
|
||||
libnghttp2_dep,
|
||||
libmicrohttpd_dep,
|
||||
|
|
|
@ -362,7 +362,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 50, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 482196050520000);
|
||||
ABTS_TRUE(tc, t == 482196050520000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1996-12-19T16:39:57-0800");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -376,7 +376,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 57, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 851042397000000);
|
||||
ABTS_TRUE(tc, t == 851042397000000LL);
|
||||
|
||||
tm.tm_mday = 19;
|
||||
tm.tm_hour = 16;
|
||||
|
@ -394,7 +394,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 57, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 851042397000000);
|
||||
ABTS_TRUE(tc, t == 851042397000000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1990-12-31T23:59:60Z");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -408,7 +408,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 0, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 662688000000000);
|
||||
ABTS_TRUE(tc, t == 662688000000000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1990-12-31T15:59:60-0800");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -422,7 +422,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 0, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 662688000000000);
|
||||
ABTS_TRUE(tc, t == 662688000000000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1990-12-31T15:59:60-08:00");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -436,7 +436,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 0, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
ABTS_TRUE(tc, t == 662688000000000);
|
||||
ABTS_TRUE(tc, t == 662688000000000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1987-01-01T12:00:27.87+0020");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -450,9 +450,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 27, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
#if 0 /* TODO */
|
||||
ABTS_TRUE(tc, t == 536499627870000);
|
||||
#endif
|
||||
ABTS_TRUE(tc, t == 536499627870000LL);
|
||||
|
||||
rc = ogs_sbi_time_from_string(&t, "1987-01-01T12:00:27.87+0020");
|
||||
ABTS_INT_EQUAL(tc, 1, rc);
|
||||
|
@ -466,9 +464,7 @@ static void sbi_message_test4(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, 27, tm.tm_sec);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_isdst);
|
||||
ABTS_INT_EQUAL(tc, 0, tm.tm_gmtoff);
|
||||
#if 0 /* TODO */
|
||||
ABTS_TRUE(tc, t == 536499627870000);
|
||||
#endif
|
||||
ABTS_TRUE(tc, t == 536499627870000LL);
|
||||
}
|
||||
|
||||
static void sbi_message_test5(abts_case *tc, void *data)
|
||||
|
|
Loading…
Reference in New Issue