? Thu, 11 May 2023 22:15:49 +0800 Jinsong Zhao <jszhao at yeah.net> ?????:> > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz > > = "")) > [1] "1970-01-01 12:00:00 CST" > > is.na(d) > [1] TRUEGlad to see you're making progress! (Sometimes, is.na(strptime(...)) =TRUE is what progress looks like.) is.na.POSIXlt works by converting the "unpacked" date+time into POSIXct (seconds since 1970-01-01 00:00 UTC) and then checking whether it's NA. Evidently, as.POSIXct(d) returns NA. (Right?) What does unclass(d) look like on FreeBSD? Does it contain any NAs itself, or do they originate somewhere in as.POSIXct(d)? My current hypothesis is that FreeBSD mktime() doesn't like something about the timezone, but I may be wrong. Is is.na(strptime( "1970-01-03 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = '')) also TRUE? -- Best regards, Ivan
On 2023/5/11 23:06, Ivan Krylov wrote:> ? Thu, 11 May 2023 22:15:49 +0800 > Jinsong Zhao <jszhao at yeah.net> ?????: > >> > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz >> > = "")) >> [1] "1970-01-01 12:00:00 CST" >> > is.na(d) >> [1] TRUE > Glad to see you're making progress! (Sometimes, is.na(strptime(...)) => TRUE is what progress looks like.) > > is.na.POSIXlt works by converting the "unpacked" date+time into POSIXct > (seconds since 1970-01-01 00:00 UTC) and then checking whether it's NA. > Evidently, as.POSIXct(d) returns NA. (Right?) > > What does unclass(d) look like on FreeBSD? Does it contain any NAs > itself, or do they originate somewhere in as.POSIXct(d)? > > My current hypothesis is that FreeBSD mktime() doesn't like something > about the timezone, but I may be wrong. Is is.na(strptime( > "1970-01-03 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = '')) also TRUE?After I post this thread to the mailing list, I dig into .Internal(as.POSIXct(d, "")). I think it may be a bug, so I filed a bug report on R's bugzilla. Yes, is.na(strptime("1970-01-03 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = '')) also TRUE. I am not familiar with any system function. I just notice that datetime.c in src/main/ of R 4.3.0 increase 500+ more lines compared to that of R 4.2.0. Thank you very much for pointing me to the right direction. Best, Jinsong
On 2023/5/11 23:06, Ivan Krylov wrote:> ? Thu, 11 May 2023 22:15:49 +0800 > Jinsong Zhao <jszhao at yeah.net> ?????: > >> > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz >> > = "")) >> [1] "1970-01-01 12:00:00 CST" >> > is.na(d) >> [1] TRUE > > Glad to see you're making progress! (Sometimes, is.na(strptime(...)) => TRUE is what progress looks like.) > > is.na.POSIXlt works by converting the "unpacked" date+time into POSIXct > (seconds since 1970-01-01 00:00 UTC) and then checking whether it's NA. > Evidently, as.POSIXct(d) returns NA. (Right?) > > What does unclass(d) look like on FreeBSD? Does it contain any NAs > itself, or do they originate somewhere in as.POSIXct(d)?I just forgot to answer your question. unclass(d) has $gmtoff with value of NA. However, in R 4.3.0 on Windows this slot also has the value of NA. as.POSIXct(d) on FreeBSD gives NA.> > My current hypothesis is that FreeBSD mktime() doesn't like something > about the timezone, but I may be wrong. Is is.na(strptime( > "1970-01-03 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = '')) also TRUE? >