11
2- R Under development (unstable) (2024-03-19 r86151 ) -- "Unsuffered Consequences"
2+ R Under development (unstable) (2024-12-03 r87418 ) -- "Unsuffered Consequences"
33Copyright (C) 2024 The R Foundation for Statistical Computing
44Platform: x86_64-pc-linux-gnu
55
@@ -15,7 +15,7 @@ Type 'demo()' for some demos, 'help()' for on-line help, or
1515'help.start()' for an HTML browser interface to help.
1616Type 'q()' to quit R.
1717
18- > ### tests of strftime (formatting POSIXlt objects).
18+ > ### tests of strftime (formatting POSIXlt objects via format.POSIXlt)
1919>
2020> Sys.setenv(TZ = "Europe/Rome")
2121>
@@ -89,4 +89,141 @@ Type 'q()' to quit R.
89892017: 01 52 00
90902018: 00 01 01
9191>
92+ > ## recycling *both* {x, format} "heavily"; digits = <n> must influence %OS<empty>; PR#17350
93+ > (fmt <- c("", paste0("%H:%M:%OS", c("", 2), " in %Y"), # || nasty (but "correct")
94+ + paste0("%Y-%m-%d", c("", paste0(" %H:%M:%OS", c("", 0, 1, 6, 9, 11))))))
95+ [1] "" "%H:%M:%OS in %Y" "%H:%M:%OS2 in %Y"
96+ [4] "%Y-%m-%d" "%Y-%m-%d %H:%M:%OS" "%Y-%m-%d %H:%M:%OS0"
97+ [7] "%Y-%m-%d %H:%M:%OS1" "%Y-%m-%d %H:%M:%OS6" "%Y-%m-%d %H:%M:%OS9"
98+ [10] "%Y-%m-%d %H:%M:%OS11"
99+ > weekD <- seq(as.Date("2020-04-01"), by = "weeks", length.out = 5 * length(fmt)) ; joff <- (0:4)*length(fmt)
100+ > weekPlt <- as.POSIXlt(weekD, tz = "UTC")
101+ > (Lf1 <- split(f1 <- format(weekPlt, format = fmt), fmt))
102+ [[1]]
103+ [1] "2020-04-01" "2020-06-10" "2020-08-19" "2020-10-28" "2021-01-06"
104+
105+ $`%H:%M:%OS in %Y`
106+ [1] "00:00:00 in 2020" "00:00:00 in 2020" "00:00:00 in 2020" "00:00:00 in 2020"
107+ [5] "00:00:00 in 2021"
108+
109+ $`%H:%M:%OS2 in %Y`
110+ [1] "00:00:00.00 in 2020" "00:00:00.00 in 2020" "00:00:00.00 in 2020"
111+ [4] "00:00:00.00 in 2020" "00:00:00.00 in 2021"
112+
113+ $`%Y-%m-%d`
114+ [1] "2020-04-22" "2020-07-01" "2020-09-09" "2020-11-18" "2021-01-27"
115+
116+ $`%Y-%m-%d %H:%M:%OS`
117+ [1] "2020-04-29 00:00:00" "2020-07-08 00:00:00" "2020-09-16 00:00:00"
118+ [4] "2020-11-25 00:00:00" "2021-02-03 00:00:00"
119+
120+ $`%Y-%m-%d %H:%M:%OS0`
121+ [1] "2020-05-06 00:00:00" "2020-07-15 00:00:00" "2020-09-23 00:00:00"
122+ [4] "2020-12-02 00:00:00" "2021-02-10 00:00:00"
123+
124+ $`%Y-%m-%d %H:%M:%OS1`
125+ [1] "2020-05-13 00:00:00.0" "2020-07-22 00:00:00.0" "2020-09-30 00:00:00.0"
126+ [4] "2020-12-09 00:00:00.0" "2021-02-17 00:00:00.0"
127+
128+ $`%Y-%m-%d %H:%M:%OS11`
129+ [1] "2020-06-03 00:00:00.01" "2020-08-12 00:00:00.01" "2020-10-21 00:00:00.01"
130+ [4] "2020-12-30 00:00:00.01" "2021-03-10 00:00:00.01"
131+
132+ $`%Y-%m-%d %H:%M:%OS6`
133+ [1] "2020-05-20 00:00:00.000000" "2020-07-29 00:00:00.000000"
134+ [3] "2020-10-07 00:00:00.000000" "2020-12-16 00:00:00.000000"
135+ [5] "2021-02-24 00:00:00.000000"
136+
137+ $`%Y-%m-%d %H:%M:%OS9`
138+ [1] "2020-05-27 00:00:00.000000" "2020-08-05 00:00:00.000000"
139+ [3] "2020-10-14 00:00:00.000000" "2020-12-23 00:00:00.000000"
140+ [5] "2021-03-03 00:00:00.000000"
141+
142+ > (Lf. <- split(f. <- format(weekPlt + 0.25, format = fmt), fmt))
143+ [[1]]
144+ [1] "2020-04-01 00:00:00" "2020-06-10 00:00:00" "2020-08-19 00:00:00"
145+ [4] "2020-10-28 00:00:00" "2021-01-06 00:00:00"
146+
147+ $`%H:%M:%OS in %Y`
148+ [1] "00:00:00 in 2020" "00:00:00 in 2020" "00:00:00 in 2020" "00:00:00 in 2020"
149+ [5] "00:00:00 in 2021"
150+
151+ $`%H:%M:%OS2 in %Y`
152+ [1] "00:00:00.25 in 2020" "00:00:00.25 in 2020" "00:00:00.25 in 2020"
153+ [4] "00:00:00.25 in 2020" "00:00:00.25 in 2021"
154+
155+ $`%Y-%m-%d`
156+ [1] "2020-04-22" "2020-07-01" "2020-09-09" "2020-11-18" "2021-01-27"
157+
158+ $`%Y-%m-%d %H:%M:%OS`
159+ [1] "2020-04-29 00:00:00" "2020-07-08 00:00:00" "2020-09-16 00:00:00"
160+ [4] "2020-11-25 00:00:00" "2021-02-03 00:00:00"
161+
162+ $`%Y-%m-%d %H:%M:%OS0`
163+ [1] "2020-05-06 00:00:00" "2020-07-15 00:00:00" "2020-09-23 00:00:00"
164+ [4] "2020-12-02 00:00:00" "2021-02-10 00:00:00"
165+
166+ $`%Y-%m-%d %H:%M:%OS1`
167+ [1] "2020-05-13 00:00:00.2" "2020-07-22 00:00:00.2" "2020-09-30 00:00:00.2"
168+ [4] "2020-12-09 00:00:00.2" "2021-02-17 00:00:00.2"
169+
170+ $`%Y-%m-%d %H:%M:%OS11`
171+ [1] "2020-06-03 00:00:00.21" "2020-08-12 00:00:00.21" "2020-10-21 00:00:00.21"
172+ [4] "2020-12-30 00:00:00.21" "2021-03-10 00:00:00.21"
173+
174+ $`%Y-%m-%d %H:%M:%OS6`
175+ [1] "2020-05-20 00:00:00.250000" "2020-07-29 00:00:00.250000"
176+ [3] "2020-10-07 00:00:00.250000" "2020-12-16 00:00:00.250000"
177+ [5] "2021-02-24 00:00:00.250000"
178+
179+ $`%Y-%m-%d %H:%M:%OS9`
180+ [1] "2020-05-27 00:00:00.250000" "2020-08-05 00:00:00.250000"
181+ [3] "2020-10-14 00:00:00.250000" "2020-12-23 00:00:00.250000"
182+ [5] "2021-03-03 00:00:00.250000"
183+
184+ > (Lf3 <- split(f3 <- format(weekPlt + 0.25, format = fmt, digits = 3), fmt))
185+ [[1]]
186+ [1] "2020-04-01 00:00:00.25" "2020-06-10 00:00:00.25" "2020-08-19 00:00:00.25"
187+ [4] "2020-10-28 00:00:00.25" "2021-01-06 00:00:00.25"
188+
189+ $`%H:%M:%OS in %Y`
190+ [1] "00:00:00.25 in 2020" "00:00:00.25 in 2020" "00:00:00.25 in 2020"
191+ [4] "00:00:00.25 in 2020" "00:00:00.25 in 2021"
192+
193+ $`%H:%M:%OS2 in %Y`
194+ [1] "00:00:00.25 in 2020" "00:00:00.25 in 2020" "00:00:00.25 in 2020"
195+ [4] "00:00:00.25 in 2020" "00:00:00.25 in 2021"
196+
197+ $`%Y-%m-%d`
198+ [1] "2020-04-22" "2020-07-01" "2020-09-09" "2020-11-18" "2021-01-27"
199+
200+ $`%Y-%m-%d %H:%M:%OS`
201+ [1] "2020-04-29 00:00:00" "2020-07-08 00:00:00" "2020-09-16 00:00:00"
202+ [4] "2020-11-25 00:00:00" "2021-02-03 00:00:00"
203+
204+ $`%Y-%m-%d %H:%M:%OS0`
205+ [1] "2020-05-06 00:00:00" "2020-07-15 00:00:00" "2020-09-23 00:00:00"
206+ [4] "2020-12-02 00:00:00" "2021-02-10 00:00:00"
207+
208+ $`%Y-%m-%d %H:%M:%OS1`
209+ [1] "2020-05-13 00:00:00.2" "2020-07-22 00:00:00.2" "2020-09-30 00:00:00.2"
210+ [4] "2020-12-09 00:00:00.2" "2021-02-17 00:00:00.2"
211+
212+ $`%Y-%m-%d %H:%M:%OS11`
213+ [1] "2020-06-03 00:00:00.21" "2020-08-12 00:00:00.21" "2020-10-21 00:00:00.21"
214+ [4] "2020-12-30 00:00:00.21" "2021-03-10 00:00:00.21"
215+
216+ $`%Y-%m-%d %H:%M:%OS6`
217+ [1] "2020-05-20 00:00:00.250000" "2020-07-29 00:00:00.250000"
218+ [3] "2020-10-07 00:00:00.250000" "2020-12-16 00:00:00.250000"
219+ [5] "2021-02-24 00:00:00.250000"
220+
221+ $`%Y-%m-%d %H:%M:%OS9`
222+ [1] "2020-05-27 00:00:00.250000" "2020-08-05 00:00:00.250000"
223+ [3] "2020-10-14 00:00:00.250000" "2020-12-23 00:00:00.250000"
224+ [5] "2021-03-03 00:00:00.250000"
225+
226+ > stopifnot(f3[2L+joff] == f3[3L+joff],
227+ + grepl("^00:00:00.25 in 202[01]", f3[2L+joff]))
228+ > ## digits = 3 had no effect on "%OS "
92229>
0 commit comments