aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/time/output.txt13
-rw-r--r--tests/time/src.c15
2 files changed, 13 insertions, 15 deletions
diff --git a/tests/time/output.txt b/tests/time/output.txt
index c8f31001..ae1fde67 100644
--- a/tests/time/output.txt
+++ b/tests/time/output.txt
@@ -20,9 +20,8 @@ localtime timezone: 1
localtime daylight: 1
localtime tzname: 1
localtime <-> mktime: 1
-old year: 102
-new year: 70
-old year again: 102
+localtime_r(1): 1
+localtime_r(2): 1
time: 1
difftime+: 268848637.000000
difftime-: -268848637.000000
@@ -30,9 +29,9 @@ difftime-: -268848637.000000
2000 days: 366
2001 days: 365
2004 days: 366
-asctime: Wed Dec 25 05:22:43 2002
-old asctime: Wed Dec 25 05:22:43 2002
-new asctime_r: Sat Jul 2 22:33:20 2011
-old asctime again: Wed Dec 25 05:22:43 2002
+asctime: Wed Dec 25 03:22:43 2002
+old asctime: Wed Dec 25 03:22:43 2002
+new asctime_r: Sat Jul 2 19:33:20 2011
+old asctime again: Wed Dec 25 03:22:43 2002
clock: 0
ctime: 0
diff --git a/tests/time/src.c b/tests/time/src.c
index df9ad264..3d4da4c2 100644
--- a/tests/time/src.c
+++ b/tests/time/src.c
@@ -44,8 +44,8 @@ int main() {
// Verify localtime() picks up timezone data.
time_t t2 = xmas2002 - 60 * 60 * 24 * 30 * 6;
tm_ptr = localtime(&t2);
- printf("localtime timezone: %d\n", (timezone + tm_ptr->tm_isdst * 60 * 60 ==
- -tm_ptr->tm_gmtoff));
+ time_t dst_diff = (tm_ptr->tm_isdst == 1) ? tm_ptr->tm_isdst * 60 * 60 : 0;
+ printf("localtime timezone: %d\n", (timezone + tm_ptr->tm_gmtoff == dst_diff));
printf("localtime daylight: %d\n", daylight == tm_ptr->tm_isdst);
printf("localtime tzname: %d\n", (!strcmp(tzname[0], tm_ptr->tm_zone) ||
!strcmp(tzname[1], tm_ptr->tm_zone)));
@@ -57,10 +57,9 @@ int main() {
time_t t3 = 0;
struct tm tm2;
localtime_r(&t3, &tm2);
- printf("old year: %d\n", tm_ptr->tm_year);
- printf("new year: %d\n", tm2.tm_year);
+ printf("localtime_r(1): %d\n", tm2.tm_year != tm_ptr->tm_year);
localtime(&xmas2002);
- printf("old year again: %d\n", tm_ptr->tm_year);
+ printf("localtime_r(2): %d\n", tm2.tm_year != tm_ptr->tm_year);
// Verify time() returns reasonable value (between 2011 and 2030).
time_t t4 = 0;
@@ -79,14 +78,14 @@ int main() {
printf("2004 days: %d\n", dysize(2004));
// Verify asctime() formatting().
- printf("asctime: %s", asctime(localtime(&xmas2002)));
+ printf("asctime: %s", asctime(gmtime(&xmas2002)));
// Verify asctime_r() doesn't clobber static data.
time_t t6 = 1309635200ll;
- tm_ptr = localtime(&xmas2002);
+ tm_ptr = gmtime(&xmas2002);
char* formatted = asctime(tm_ptr);
char buffer[32];
- asctime_r(localtime(&t6), buffer);
+ asctime_r(gmtime(&t6), buffer);
printf("old asctime: %s", formatted);
printf("new asctime_r: %s", buffer);
asctime_r(tm_ptr, buffer);