| Line 1... |
Line 1... |
| 1 |
### Tests of often platform-dependent features of the POSIX[cl]t implementation.
|
1 |
### Tests of often platform-dependent features of the POSIX[cl]t implementation.
|
| 2 |
|
2 |
|
| 3 |
### Expect differences, historically with 32-bit time_t and platforms
|
3 |
### Expect differences, historically with 32-bit time_t and platforms
|
| 4 |
### without tm_zone/tm_gmtoff.
|
4 |
### without tm_zone/tm_gmtoff.
|
| - |
|
5 |
### Also with musl (wrongly using current not historic "zone" abbreviations).
|
| 5 |
### Please use the R-internal version for .Rout.save.
|
6 |
### Please use the R-internal version for .Rout.save.
|
| - |
|
7 |
## IGNORE_RDIFF_BEGIN
|
| - |
|
8 |
(tzCtype <- sessionInfo()[["tzcode_type"]])
|
| - |
|
9 |
## IGNORE_RDIFF_END
|
| 6 |
|
10 |
|
| 7 |
z <- ISOdate(1890:1912, 1, 10, tz="UTC")
|
11 |
z <- ISOdate(1890:1912, 1, 10, tz="UTC")
|
| 8 |
## Rome changed to CET for 1894
|
12 |
## Rome changed to CET for 1894
|
| 9 |
as.POSIXlt(z, tz="Europe/Rome")
|
13 |
as.POSIXlt(z, tz="Europe/Rome")
|
| 10 |
## Paris changed to PMT for 1892, WET for 1912
|
14 |
## Paris changed to PMT for 1892, WET for 1912
|
| Line 72... |
Line 76... |
| 72 |
for(i in seq_along(years)) {
|
76 |
for(i in seq_along(years)) {
|
| 73 |
zz$year = years[i] - 1900
|
77 |
zz$year = years[i] - 1900
|
| 74 |
y[i] <- strftime(zz)
|
78 |
y[i] <- strftime(zz)
|
| 75 |
}
|
79 |
}
|
| 76 |
## IGNORE_RDIFF_BEGIN
|
80 |
## IGNORE_RDIFF_BEGIN
|
| 77 |
(tzCtype <- sessionInfo()[["tzcode_type"]])
|
- |
|
| 78 |
y
|
81 |
y
|
| 79 |
## IGNORE_RDIFF_END
|
82 |
## IGNORE_RDIFF_END
|
| 80 |
|
83 |
|
| 81 |
y <- double(length(years))
|
84 |
y <- double(length(years))
|
| 82 |
for(i in seq_along(years)) {
|
85 |
for(i in seq_along(years)) {
|
| Line 137... |
Line 140... |
| 137 |
format(x2, "%a, %d %b %Y %H:%M:%S %Z")
|
140 |
format(x2, "%a, %d %b %Y %H:%M:%S %Z")
|
| 138 |
|
141 |
|
| 139 |
## offsets not in whole hours:
|
142 |
## offsets not in whole hours:
|
| 140 |
x3 <- strptime("2022-01-01", "%Y-%m-%d", tz = "Australia/Adelaide")
|
143 |
x3 <- strptime("2022-01-01", "%Y-%m-%d", tz = "Australia/Adelaide")
|
| 141 |
format(as.POSIXct(x3), "%a, %d %b %Y %H:%M:%S %z") # +10h30m
|
144 |
format(as.POSIXct(x3), "%a, %d %b %Y %H:%M:%S %z") # +10h30m
|
| 142 |
# macOS' strftime printed the next two wrong.
|
- |
|
| 143 |
# Liberia does/did not have DST
|
145 |
# Liberia does/did not have DST and, before 1972-01-07, used MMT (-44m30s)
|
| 144 |
x4 <- strptime("1971-01-01", "%Y-%m-%d", tz = "Africa/Monrovia")
|
146 |
x4 <- strptime("1971-01-01", "%Y-%m-%d", tz = "Africa/Monrovia")
|
| 145 |
y4 <- as.POSIXct(x4)
|
147 |
y4 <- as.POSIXct(x4)
|
| 146 |
|
- |
|
| - |
|
148 |
lt4 <- unclass(as.POSIXlt(y4))
|
| 147 |
## IGNORE_RDIFF_BEGIN
|
149 |
## IGNORE_RDIFF_BEGIN
|
| 148 |
str(lt4 <- unclass(as.POSIXlt(y4))) # correct gmtoff, printed wrong as -44m
|
150 |
attr(lt4, "tzone")
|
| 149 |
# glibc prints an abbreviation for DST.
|
151 |
## glibc prints an abbreviation for DST. internal and musl leave it blank.
|
| 150 |
## IGNORE_RDIFF_END
|
152 |
## IGNORE_RDIFF_END
|
| 151 |
stopifnot(identical(attr(lt4, "tzone"),
|
153 |
stopifnot(identical(
|
| - |
|
154 |
attr(lt4, "tzone") |> trimws(), # ignore " " (internal) vs. "" (musl)
|
| 152 |
c("Africa/Monrovia", "GMT", if(grepl("glibc", tzCtype)) "GMT" else " ")),
|
155 |
c("Africa/Monrovia", "GMT", if(grepl("glibc", tzCtype)) "GMT" else "")
|
| - |
|
156 |
))
|
| 153 |
identical(`attr<-`(lt4, "tzone", NULL),
|
157 |
str(`attr<-`(lt4, "tzone", NULL))
|
| 154 |
structure(list(sec = 0, min = 0L, hour = 0L, mday = 1L, mon = 0L, year = 71L,
|
158 |
## musl wrongly gives zone="GMT" (the current, not that at the time).
|
| 155 |
wday = 5L, yday = 0L, isdst = 0L, zone = "MMT", gmtoff = -2670L),
|
- |
|
| 156 |
balanced = TRUE)))
|
159 |
## macOS' strftime printed gmtoff wrong as -44m.
|
| 157 |
|
- |
|
| 158 |
format(y4, "%a, %d %b %Y %H:%M:%S %z")
|
160 |
format(y4, "%a, %d %b %Y %H:%M:%S %z")
|
| - |
|
161 |
|
| 159 |
## timezones in 1900 might not be supported
|
162 |
## timezones in 1900 might not be supported
|
| 160 |
x5 <- strptime("1900-03-01", "%Y-%m-%d", tz = "Europe/Paris")
|
163 |
x5 <- strptime("1900-03-01", "%Y-%m-%d", tz = "Europe/Paris")
|
| 161 |
y5 <- as.POSIXct(x5)
|
164 |
y5 <- as.POSIXct(x5)
|
| 162 |
str(unclass(as.POSIXlt(y5))) # ditto
|
165 |
str(unclass(as.POSIXlt(y5))) # ditto
|
| 163 |
format(y5, "%a, %d %b %Y %H:%M:%S %z")
|
166 |
format(y5, "%a, %d %b %Y %H:%M:%S %z")
|