schochastics / timeless

A general purpose date(time) parser for R
https://schochastics.github.io/timeless/
Other
19 stars 2 forks source link

weird behaviour for some datetimes #9

Closed schochastics closed 6 months ago

schochastics commented 6 months ago
library(chronos)
chronos("30/03/1997 00:00:00")
#> [1] "1997-03-30 CET"
chronos("30/03/1997 01:00:00")
#> [1] "1997-03-30 01:00:00 CET"
chronos("30/03/1997 02:00:00")
#> [1] "1997-03-30 01:00:00 CET" <-----------------
chronos("30/03/1997 03:00:00")
#> [1] "1997-03-30 03:00:00 CEST"
chronos("30/03/1997 04:00:00")
#> [1] "1997-03-30 04:00:00 CEST"

parse_datetime("30/03/1997 00:00:00")
#> [1] "1997-03-30 00:00:00"
parse_datetime("30/03/1997 01:00:00")
#> [1] "1997-03-30 01:00:00"
parse_datetime("30/03/1997 02:00:00")
#> [1] "1997-03-30 02:00:00" <-----------------
parse_datetime("30/03/1997 03:00:00")
#> [1] "1997-03-30 03:00:00"
parse_datetime("30/03/1997 04:00:00")
#> [1] "1997-03-30 04:00:00"

Created on 2024-02-26 with reprex v2.1.0

schochastics commented 6 months ago
chronos::chronos("30/03/1997 02:43:12")
#> Error in parse_datetime_rs(x, formats, out_datetime): user function panicked: parse_datetime_rs
chronos::chronos("30/03/1997 01:43:12")
#> [1] "1997-03-30 01:43:12 CET"

Created on 2024-02-26 with reprex v2.1.0

schochastics commented 6 months ago
R> as.POSIXct("30/03/1997 01:43:12",format="%d/%m/%Y %H:%M:%S")
[1] "1997-03-30 01:43:12 CET"

R> as.POSIXct("30/03/1997 02:43:12",format="%d/%m/%Y %H:%M:%S")
[1] "1997-03-30 01:43:12 CET"
schochastics commented 6 months ago
chronos::chronos("Sunday, 28 September 1986 02:06 AM")
#> thread '<unnamed>' panicked at src/lib.rs:31:64:
#>Ambiguous local time, ranging from 1986-09-28T02:06:00+01:00 to 1986-09-28T02:06:00+02:00
#>thread '<unnamed>' panicked at src/lib.rs:20:1:
#>explicit panic
#> Error in parse_datetime_rs(x, formats, out_datetime): user function panicked: parse_datetime_rs

Created on 2024-02-26 with reprex v2.1.0

schochastics commented 6 months ago

turns out, I forgot that daylight savings exists...