The R Project SVN R

Rev

Rev 90134 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 90134 Rev 90139
Line 1... Line 1...
1
 
1
 
2
R Under development (unstable) (2026-06-09 r90126) -- "Unsuffered Consequences"
2
R Under development (unstable) (2026-06-12 r90138) -- "Unsuffered Consequences"
3
Copyright (C) 2026 The R Foundation for Statistical Computing
3
Copyright (C) 2026 The R Foundation for Statistical Computing
4
Platform: aarch64-apple-darwin25.4.0
4
Platform: x86_64-pc-linux-gnu
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
8
Type 'license()' or 'licence()' for distribution details.
8
Type 'license()' or 'licence()' for distribution details.
9
 
9
 
Line 17... Line 17...
17
 
17
 
18
> ### more date-time tests where the output is to be checked.
18
> ### more date-time tests where the output is to be checked.
19
> 
19
> 
20
> ## Expect differences, especially for platforms without tm_zone/tm_gmtoff.
20
> ## Expect differences, especially for platforms without tm_zone/tm_gmtoff.
21
> ## Please use the R-internal version for .Rout.save
21
> ## Please use the R-internal version for .Rout.save
-
 
22
> ## IGNORE_RDIFF_BEGIN
-
 
23
> (tzCtype <- sessionInfo()[["tzcode_type"]])
-
 
24
[1] "internal"
-
 
25
> ## IGNORE_RDIFF_END
22
> 
26
> 
23
> options(warn = 1L)
27
> options(warn = 1L)
24
> si <-  sessionInfo()
-
 
25
> 
28
> 
26
> ## tests of "POSIXlt" objects
29
> ## tests of "POSIXlt" objects
27
> xU <- strptime("2022-01-01", "%Y-%m-%d", tz = "UTC")
30
> xU <- strptime("2022-01-01", "%Y-%m-%d", tz = "UTC")
28
> xU
31
> xU
29
[1] "2022-01-01 UTC"
32
[1] "2022-01-01 UTC"
Line 43... Line 46...
43
 - attr(*, "tzone")= chr "UTC"
46
 - attr(*, "tzone")= chr "UTC"
44
 - attr(*, "balanced")= logi TRUE
47
 - attr(*, "balanced")= logi TRUE
45
> 
48
> 
46
> x0 <- strptime("2022-01-01", "%Y-%m-%d") # current time zone
49
> x0 <- strptime("2022-01-01", "%Y-%m-%d") # current time zone
47
> ## IGNORE_RDIFF_BEGIN
50
> ## IGNORE_RDIFF_BEGIN
48
> si # sessionInfo() incl "tzcode source" :
-
 
49
R Under development (unstable) (2026-06-09 r90126)
-
 
50
Platform: x86_64-pc-linux-gnu
-
 
51
Running under: Fedora Linux 42 (Adams)
-
 
52
 
-
 
53
Matrix products: default
-
 
54
BLAS:   /sfs/u/maechler/R/D/r-devel/F42-64-inst/lib/libRblas.so 
-
 
55
LAPACK: /usr/lib64/liblapack.so.3.12.0  LAPACK version 3.12.0
-
 
56
 
-
 
57
locale:
-
 
58
[1] C
-
 
59
 
-
 
60
time zone: Europe/Zurich
-
 
61
tzcode source: system (glibc)
-
 
62
 
-
 
63
attached base packages:
-
 
64
[1] stats     graphics  grDevices utils     datasets  methods   base     
-
 
65
 
-
 
66
loaded via a namespace (and not attached):
-
 
67
[1] compiler_4.7.0
-
 
68
> (tzCtype <- si[["tzcode_type"]])
-
 
69
[1] "system (glibc)"
-
 
70
> x0
51
> x0
71
[1] "2022-01-01 GMT"
52
[1] "2022-01-01 CET"
72
> str(unclass(x0))
53
> str(unclass(x0))
73
List of 11
54
List of 11
74
 $ sec   : num 0
55
 $ sec   : num 0
75
 $ min   : int 0
56
 $ min   : int 0
76
 $ hour  : int 0
57
 $ hour  : int 0
Line 78... Line 59...
78
 $ mon   : int 0
59
 $ mon   : int 0
79
 $ year  : int 122
60
 $ year  : int 122
80
 $ wday  : int 6
61
 $ wday  : int 6
81
 $ yday  : int 0
62
 $ yday  : int 0
82
 $ isdst : int 0
63
 $ isdst : int 0
83
 $ zone  : chr "GMT"
64
 $ zone  : chr "CET"
84
 $ gmtoff: int NA
65
 $ gmtoff: int NA
85
 - attr(*, "tzone")= chr [1:3] "" "GMT" "BST"
66
 - attr(*, "tzone")= chr [1:3] "" "CET" "CEST"
86
 - attr(*, "balanced")= logi TRUE
67
 - attr(*, "balanced")= logi TRUE
87
> ## IGNORE_RDIFF_END
68
> ## IGNORE_RDIFF_END
88
> 
69
> 
89
> x1 <- strptime("2022-07-01", "%Y-%m-%d", tz = "Europe/London")
70
> x1 <- strptime("2022-07-01", "%Y-%m-%d", tz = "Europe/London")
90
> x1
71
> x1
Line 143... Line 124...
143
 $ zone  : chr ""
124
 $ zone  : chr ""
144
 $ gmtoff: int 10800
125
 $ gmtoff: int 10800
145
 - attr(*, "tzone")= chr [1:3] "Europe/Vienna" "CET" "CEST"
126
 - attr(*, "tzone")= chr [1:3] "Europe/Vienna" "CET" "CEST"
146
 - attr(*, "balanced")= logi TRUE
127
 - attr(*, "balanced")= logi TRUE
147
> 
128
> 
-
 
129
> # Fiji tried DST in some previous years, but not since 2021
148
> x4 <- strptime("2022-07-01", "%Y-%m-%d", tz ="Pacific/Fiji")
130
> x4 <- strptime("2022-07-01", "%Y-%m-%d", tz ="Pacific/Fiji")
149
> x4
131
> x4
150
[1] "2022-07-01 +12"
132
[1] "2022-07-01 +12"
151
> str(unclass(x4)) # abbreviations may be numbers.
133
> str(unclass(x4)) # abbreviations may be numbers.
152
List of 11
134
List of 11
Line 166... Line 148...
166
> # Kiribati does/did not have DST, so second abbreviation may be repeat or empty
148
> # Kiribati does/did not have DST, so second abbreviation may be repeat or empty
167
> x5 <- strptime("2022-07-01", "%Y-%m-%d", tz ="Pacific/Kiritimati")
149
> x5 <- strptime("2022-07-01", "%Y-%m-%d", tz ="Pacific/Kiritimati")
168
> x5
150
> x5
169
[1] "2022-07-01 +14"
151
[1] "2022-07-01 +14"
170
> ## IGNORE_RDIFF_BEGIN
152
> ## IGNORE_RDIFF_BEGIN
171
> str(unclass(x5)) # does not have DST, hence no DST abbreviation except on glibc
153
> attr(x5, "tzone") # does not have DST, hence no DST abbreviation except on glibc
-
 
154
[1] "Pacific/Kiritimati" "+14"                "   "               
-
 
155
> ## IGNORE_RDIFF_END
-
 
156
> stopifnot(identical(
-
 
157
+     attr(x5, "tzone") |> trimws(), # ignore "   " (internal) vs. "" (musl)
-
 
158
+     c("Pacific/Kiritimati", "+14", if(grepl("glibc", tzCtype)) "+14" else "")
-
 
159
+ ))
-
 
160
> str(unclass(`attr<-`(x5, "tzone", NULL)))
172
List of 11
161
List of 11
173
 $ sec   : num 0
162
 $ sec   : num 0
174
 $ min   : int 0
163
 $ min   : int 0
175
 $ hour  : int 0
164
 $ hour  : int 0
176
 $ mday  : int 1
165
 $ mday  : int 1
Line 179... Line 168...
179
 $ wday  : int 5
168
 $ wday  : int 5
180
 $ yday  : int 181
169
 $ yday  : int 181
181
 $ isdst : int 0
170
 $ isdst : int 0
182
 $ zone  : chr "+14"
171
 $ zone  : chr "+14"
183
 $ gmtoff: int NA
172
 $ gmtoff: int NA
184
 - attr(*, "tzone")= chr [1:3] "Pacific/Kiritimati" "+14" "   "
-
 
185
 - attr(*, "balanced")= logi TRUE
173
 - attr(*, "balanced")= logi TRUE
186
> ## IGNORE_RDIFF_END
-
 
187
> u5 <- unclass(x5)
-
 
188
> u5_ <- `attr<-`(u5, "tzone", NULL)
-
 
189
> stopifnot(exprs = {
-
 
190
+     identical(attr(u5, "tzone"),
-
 
191
+               c("Pacific/Kiritimati", "+14", if(grepl("glibc", tzCtype)) "+14" else "   "))
-
 
192
+     identical(u5_, structure(
-
 
193
+                   list(sec = 0, min = 0L, hour = 0L, mday = 1L, mon = 6L, year = 122L,
-
 
194
+                        wday = 5L, yday = 181L, isdst = 0L, zone = "+14", gmtoff = NA_integer_),
-
 
195
+                   balanced = TRUE))
-
 
196
+ })
-
 
197
> 
174
> 
198
> 
175
> 
199
> ## edge of range and out of range offsets
176
> ## edge of range and out of range offsets
200
> strptime("2022-01-01 +1400", "%Y-%m-%d %z", tz = "UTC")
177
> strptime("2022-01-01 +1400", "%Y-%m-%d %z", tz = "UTC")
201
[1] "2021-12-31 10:00:00 UTC"
178
[1] "2021-12-31 10:00:00 UTC"
Line 286... Line 263...
286
"2022-09-01" "2022-09-08" "2022-09-15" "2022-09-22" "2022-09-29" "2022-10-06" 
263
"2022-09-01" "2022-09-08" "2022-09-15" "2022-09-22" "2022-09-29" "2022-10-06" 
287
      week 7       week 8       week 9      week 10 
264
      week 7       week 8       week 9      week 10 
288
"2022-10-13" "2022-10-20" "2022-10-27" "2022-11-03" 
265
"2022-10-13" "2022-10-20" "2022-10-27" "2022-11-03" 
289
> ## IGNORE_RDIFF_BEGIN
266
> ## IGNORE_RDIFF_BEGIN
290
> as.POSIXct(y)
267
> as.POSIXct(y)
291
          week 1           week 2           week 3           week 4 
268
           week 1            week 2            week 3            week 4 
292
"2022-09-01 BST" "2022-09-08 BST" "2022-09-15 BST" "2022-09-22 BST" 
269
"2022-09-01 CEST" "2022-09-08 CEST" "2022-09-15 CEST" "2022-09-22 CEST" 
293
          week 5           week 6           week 7           week 8 
270
           week 5            week 6            week 7            week 8 
294
"2022-09-29 BST" "2022-10-06 BST" "2022-10-13 BST" "2022-10-20 BST" 
271
"2022-09-29 CEST" "2022-10-06 CEST" "2022-10-13 CEST" "2022-10-20 CEST" 
295
          week 9          week 10 
272
           week 9           week 10 
296
"2022-10-27 BST" "2022-11-03 GMT" 
273
"2022-10-27 CEST"  "2022-11-03 CET" 
297
> (yy <- as.POSIXlt(y))
274
> (yy <- as.POSIXlt(y))
298
          week 1           week 2           week 3           week 4 
275
           week 1            week 2            week 3            week 4 
299
"2022-09-01 BST" "2022-09-08 BST" "2022-09-15 BST" "2022-09-22 BST" 
276
"2022-09-01 CEST" "2022-09-08 CEST" "2022-09-15 CEST" "2022-09-22 CEST" 
300
          week 5           week 6           week 7           week 8 
277
           week 5            week 6            week 7            week 8 
301
"2022-09-29 BST" "2022-10-06 BST" "2022-10-13 BST" "2022-10-20 BST" 
278
"2022-09-29 CEST" "2022-10-06 CEST" "2022-10-13 CEST" "2022-10-20 CEST" 
302
          week 9          week 10 
279
           week 9           week 10 
303
"2022-10-27 BST" "2022-11-03 GMT" 
280
"2022-10-27 CEST"  "2022-11-03 CET" 
304
> unclass(yy)
281
> unclass(yy)
305
$sec
282
$sec
306
 [1] 0 0 0 0 0 0 0 0 0 0
283
 [1] 0 0 0 0 0 0 0 0 0 0
307
 
284
 
308
$min
285
$min
Line 329... Line 306...
329
 
306
 
330
$isdst
307
$isdst
331
 [1] 1 1 1 1 1 1 1 1 1 0
308
 [1] 1 1 1 1 1 1 1 1 1 0
332
 
309
 
333
$zone
310
$zone
334
 [1] "BST" "BST" "BST" "BST" "BST" "BST" "BST" "BST" "BST" "GMT"
311
 [1] "CEST" "CEST" "CEST" "CEST" "CEST" "CEST" "CEST" "CEST" "CEST" "CET" 
335
 
312
 
336
$gmtoff
313
$gmtoff
337
 [1] NA NA NA NA NA NA NA NA NA NA
314
 [1] NA NA NA NA NA NA NA NA NA NA
338
 
315
 
339
attr(,"tzone")
316
attr(,"tzone")
340
[1] ""    "GMT" "BST"
317
[1] ""     "CET"  "CEST"
341
attr(,"balanced")
318
attr(,"balanced")
342
[1] TRUE
319
[1] TRUE
343
> 
320
> 
344
> strptime(y, "%Y-%m-%d")
321
> strptime(y, "%Y-%m-%d")
345
          week 1           week 2           week 3           week 4 
322
           week 1            week 2            week 3            week 4 
346
"2022-09-01 BST" "2022-09-08 BST" "2022-09-15 BST" "2022-09-22 BST" 
323
"2022-09-01 CEST" "2022-09-08 CEST" "2022-09-15 CEST" "2022-09-22 CEST" 
347
          week 5           week 6           week 7           week 8 
324
           week 5            week 6            week 7            week 8 
348
"2022-09-29 BST" "2022-10-06 BST" "2022-10-13 BST" "2022-10-20 BST" 
325
"2022-09-29 CEST" "2022-10-06 CEST" "2022-10-13 CEST" "2022-10-20 CEST" 
349
          week 9          week 10 
326
           week 9           week 10 
350
"2022-10-27 BST" "2022-11-03 GMT" 
327
"2022-10-27 CEST"  "2022-11-03 CET" 
351
> strftime(y, "%Y-%m-%d")
328
> strftime(y, "%Y-%m-%d")
352
      week 1       week 2       week 3       week 4       week 5       week 6 
329
      week 1       week 2       week 3       week 4       week 5       week 6 
353
"2022-09-01" "2022-09-08" "2022-09-15" "2022-09-22" "2022-09-29" "2022-10-06" 
330
"2022-09-01" "2022-09-08" "2022-09-15" "2022-09-22" "2022-09-29" "2022-10-06" 
354
      week 7       week 8       week 9      week 10 
331
      week 7       week 8       week 9      week 10 
355
"2022-10-13" "2022-10-20" "2022-10-27" "2022-11-03" 
332
"2022-10-13" "2022-10-20" "2022-10-27" "2022-11-03" 
356
> y2 <- paste(y, "10:01:02"); names(y2) <- names(y)
333
> y2 <- paste(y, "10:01:02"); names(y2) <- names(y)
357
> fmt <- c("%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S %Z")
334
> fmt <- c("%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S %Z")
358
> (strptime(y2, fmt[1:2]) -> sy2)
335
> (strptime(y2, fmt[1:2]) -> sy2)
359
                   week 1                    week 2                    week 3 
336
                    week 1                     week 2 
360
"2022-09-01 00:00:00 BST" "2022-09-08 10:01:02 BST" "2022-09-15 00:00:00 BST" 
337
"2022-09-01 00:00:00 CEST" "2022-09-08 10:01:02 CEST" 
-
 
338
                    week 3                     week 4 
-
 
339
"2022-09-15 00:00:00 CEST" "2022-09-22 10:01:02 CEST" 
361
                   week 4                    week 5                    week 6 
340
                    week 5                     week 6 
362
"2022-09-22 10:01:02 BST" "2022-09-29 00:00:00 BST" "2022-10-06 10:01:02 BST" 
341
"2022-09-29 00:00:00 CEST" "2022-10-06 10:01:02 CEST" 
363
                   week 7                    week 8                    week 9 
342
                    week 7                     week 8 
364
"2022-10-13 00:00:00 BST" "2022-10-20 10:01:02 BST" "2022-10-27 00:00:00 BST" 
343
"2022-10-13 00:00:00 CEST" "2022-10-20 10:01:02 CEST" 
365
                  week 10 
344
                    week 9                    week 10 
366
"2022-11-03 10:01:02 GMT" 
345
"2022-10-27 00:00:00 CEST"  "2022-11-03 10:01:02 CET" 
367
> ## IGNORE_RDIFF_END
346
> ## IGNORE_RDIFF_END
368
> sy2.15 <- strptime(y2, rep(fmt[1:2], length = 15)) # failed to recycle names
347
> sy2.15 <- strptime(y2, rep(fmt[1:2], length = 15)) # failed to recycle names
369
> stopifnot(suppressWarnings(sy2 == sy2.15))
348
> stopifnot(suppressWarnings(sy2 == sy2.15))
370
> 
349
> 
371
> xl. <- xl[1:9] # length(fmt) == 3 -- fully recycles in xl.
350
> xl. <- xl[1:9] # length(fmt) == 3 -- fully recycles in xl.
Line 422... Line 401...
422
             "2022-09-08"     "2022-09-15 00:00:00" "2022-09-22 00:00:00 UTC" 
401
             "2022-09-08"     "2022-09-15 00:00:00" "2022-09-22 00:00:00 UTC" 
423
                     <NA> 
402
                     <NA> 
424
             "2022-09-29" 
403
             "2022-09-29" 
425
> 
404
> 
426
> cat('Time elapsed: ', proc.time(),'\n')
405
> cat('Time elapsed: ', proc.time(),'\n')
427
Time elapsed:  0.096 0.021 0.124 0.005 0.006 
406
Time elapsed:  0.133 0.024 0.233 0.004 0.001 
428
> 
407
>