| 73760 |
maechler |
1 |
#### Test R's (64-bit) date-time functions .. output tested *sloppily*
|
| 64342 |
ripley |
2 |
|
|
|
3 |
## R's internal fixes are used on 32-bit platforms.
|
| 70779 |
ripley |
4 |
## macOS gets these wrong: see HAVE_WORKING_64BIT_MKTIME
|
| 64342 |
ripley |
5 |
|
|
|
6 |
Sys.setenv(TZ = "UTC")
|
|
|
7 |
(z <- as.POSIXct("1848-01-01 12:00"))
|
|
|
8 |
c(unclass(z))
|
|
|
9 |
(z <- as.POSIXct("2040-01-01 12:00"))
|
|
|
10 |
c(unclass(z))
|
|
|
11 |
(z <- as.POSIXct("2040-07-01 12:00"))
|
|
|
12 |
c(unclass(z))
|
|
|
13 |
|
|
|
14 |
Sys.setenv(TZ = "Europe/London") # pretty much portable.
|
|
|
15 |
(z <- as.POSIXct("1848-01-01 12:00"))
|
|
|
16 |
c(unclass(z))
|
| 75856 |
ripley |
17 |
## We don't know the operation of timezones next year let alone in 2040
|
| 75348 |
ripley |
18 |
## but these should at least round-trip
|
| 75855 |
ripley |
19 |
## These got the wrong timezone on Linux with glibc 2.2[67]
|
| 75348 |
ripley |
20 |
as.POSIXct("2040-01-01 12:00")
|
|
|
21 |
as.POSIXct("2040-07-01 12:00")
|
| 64342 |
ripley |
22 |
|
| 75348 |
ripley |
23 |
Sys.setenv(TZ = "EST5EDT") # also pretty much portable.
|
| 87256 |
smeyer |
24 |
## However, tzdata 2024b changed this from EST to LMT (and by 238s)
|
| 87359 |
maechler |
25 |
## IGNORE_RDIFF_BEGIN
|
| 64342 |
ripley |
26 |
(z <- as.POSIXct("1848-01-01 12:00"))
|
|
|
27 |
c(unclass(z))
|
| 87359 |
maechler |
28 |
## IGNORE_RDIFF_END
|
| 75855 |
ripley |
29 |
## see comment above
|
| 75348 |
ripley |
30 |
as.POSIXct("2040-01-01 12:00")
|
|
|
31 |
as.POSIXct("2040-07-01 12:00")
|
| 64517 |
ripley |
32 |
|
|
|
33 |
## PR15613: had day as > 24hrs.
|
|
|
34 |
as.POSIXlt(ISOdate(2071,1,13,0,0,tz="Etc/GMT-1"))$wday
|
|
|
35 |
as.POSIXlt(ISOdate(2071,1,13,0,1,tz="Etc/GMT-1"))$wday
|
| 64816 |
ripley |
36 |
|
|
|
37 |
|
| 75348 |
ripley |
38 |
## Incorrect use of %b should work even though abbreviation does match
|
| 78278 |
maechler |
39 |
Sys.setlocale("LC_TIME", "C") # to be sure
|
| 64816 |
ripley |
40 |
stopifnot(!is.na(strptime("11-August-1903", "%d-%b-%Y")))
|
| 77990 |
ripley |
41 |
|
| 83133 |
maechler |
42 |
## Prior to R 4.0.0 this overflowed an array. Now gives a warning
|
| 77990 |
ripley |
43 |
|
|
|
44 |
z <- paste("2017", c(1,365,366), sep = "-")
|
|
|
45 |
(zz <- strptime(z, "%Y-%j"))
|
|
|
46 |
stopifnot(identical(is.na(zz), c(FALSE, FALSE, TRUE)))
|
| 89534 |
maechler |
47 |
|
|
|
48 |
cat('Time elapsed: ', proc.time(),'\n')
|