FreeBSD Bugzilla – Attachment 242774 Details for
Bug 271170
math/R: error: date-time conversions do not work in 2020 -- is tzdata installed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Small test program extracted from R's configure script
test_time.c (text/plain), 3.84 KB, created by
Joseph Mingrone
on 2023-06-14 14:46:02 UTC
(
hide
)
Description:
Small test program extracted from R's configure script
Filename:
MIME Type:
Creator:
Joseph Mingrone
Created:
2023-06-14 14:46:02 UTC
Size:
3.84 KB
patch
obsolete
>#include <stdlib.h> >#include <time.h> >#include <stdio.h> > >#define PRINT > >int main(void) { > struct tm tm, *stm; > time_t res; > putenv("TZ=UTC"); > tm.tm_sec = tm.tm_min = 0; tm.tm_hour = 12; > tm.tm_mday = 1; tm.tm_mon = 0; tm.tm_year = 120; tm.tm_isdst = 0; > // test 2020-01-01 > res = mktime(&tm); >#ifdef PRINT > printf("day %ld\n", res); >#else > if(res != 1577880000L) exit(1); >#endif > // and can we go back to POSIXlt? >#ifdef HAVE_GMTIME_R > stm = gmtime_r(&res, &tm); >#else > stm = gmtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 0 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 0) exit(10); >#endif > tm.tm_mon = 6; tm.tm_isdst = 0; > // test 2020-07-01 > res = mktime(&tm); >#ifdef PRINT > printf("res %ld\n", res); >#else > if(res != 1593604800L) exit(2); >#endif >#ifdef HAVE_GMTIME_R > stm = gmtime_r(&res, &tm); >#else > stm = gmtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 6 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 0) exit(20); >#endif > > putenv("TZ=Europe/London"); > tm.tm_sec = tm.tm_min = 0; tm.tm_hour = 12; > tm.tm_mday = 1; tm.tm_mon = 0; tm.tm_year = 120; tm.tm_isdst = -1; > // test 2020-01-01, whoch is assumed to be in GMT > res = mktime(&tm); >#ifdef PRINT > printf("res %ld\n", res); >#else > if(res != 1577880000L) exit(3); >#endif >#ifdef HAVE_LOCALTIME_R > stm = localtime_r(&res, &tm); >#else > stm = localtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 0 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 0) exit(30); >#endif > tm.tm_mon = 6; tm.tm_isdst = -1; > // test 2020-07-01 which is assumed to be in BST > res = mktime(&tm); >#ifdef PRINT > printf("res %ld\n", res); >#else > if(res != 1593601200L) exit(4); >#endif >#ifdef HAVE_LOCALTIME_R > stm = localtime_r(&res, &tm); >#else > stm = localtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 6 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 1) exit(40); >#endif > putenv("TZ=Pacific/Auckland"); > tm.tm_sec = tm.tm_min = 0; tm.tm_hour = 12; > tm.tm_mday = 1; tm.tm_mon = 0; tm.tm_year = 120; tm.tm_isdst = -1; > res = mktime(&tm); >#ifdef PRINT > printf("res %ld\n", res); >#else > if(res != 1577833200L) exit(5); >#endif >#ifdef HAVE_LOCALTIME_R > stm = localtime_r(&res, &tm); >#else > stm = localtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 0 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 1) exit(50); >#endif > tm.tm_mon = 6; tm.tm_isdst = -1; > res = mktime(&tm); >#ifdef PRINT > printf("res %ld\n", res); >#else > if(res != 1593561600L) exit(6); >#endif >#ifdef HAVE_LOCALTIME_R > stm = localtime_r(&res, &tm); >#else > stm = localtime(&res); >#endif >#ifdef PRINT > printf("%d-%02d-%02d %02d:%02d:%02d\n", > 1900+stm->tm_year, 1+stm->tm_mon, stm->tm_mday, > stm->tm_hour, stm->tm_min, stm->tm_sec); >#else > if(stm->tm_year != 120 || stm->tm_mon != 6 || stm->tm_mday != 1 > || stm->tm_hour != 12 || stm-> tm_isdst != 0) exit(60); >#endif > > exit(0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 271170
: 242774 |
244258