Hi there,
When I run the following code in R 4.3.0 on FreeBSD, I got error.
> as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
The same code could give correct answer in R 4.3.0 on Windows, and R
4.1.2 on a old CentOS.
> as.POSIXct("1970-01-01 00:00.00 UTC")
[1] "1970-01-01 CST"
I confirmed that all the 3 OSes give the same time zone:
> Sys.timezone()
[1] "Asia/Shanghai"
What's wrong with the R on FreeBSD? Any hint? Thanks in advance.
Best,
Jinsong
Error in as.POSIXlt.character(x, tz, ...)
7 messages · Ivan Krylov, Jeff Newmiller, Jinsong Zhao
? Thu, 11 May 2023 16:56:41 +0800 Jinsong Zhao <jszhao at yeah.net> ?????:
When I run the following code in R 4.3.0 on FreeBSD, I got error.
> as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format
Do strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') and
strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') both return NA for
you on FreeBSD? If not, can you trace the execution using R's debugger
to see which parts are returned as NA, failing the test in
as.POSIXlt.character?
I think that strptime() should have discarded the trailing parts of the
string and matched at least the beginning (though not the ".00 UTC"
part because it doesn't correspond to the formats tried by strptime()).
Moreover, there shouldn't be significant difference between the
platforms, because R seems to always use an internal implementation of
strptime(). Are you using a multi-byte locale? (What's your
sessionInfo() on both a system where it works and the system where it
fails?)
Best regards, Ivan
I find your claim suspect... a period is not interchangeable with a colon.
On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao <jszhao at yeah.net> wrote:
Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error.
as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS.
as.POSIXct("1970-01-01 00:00.00 UTC")
[1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone:
Sys.timezone()
[1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Sent from my phone. Please excuse my brevity.
On 2023/5/11 17:24, Jeff Newmiller wrote:
I find your claim suspect... a period is not interchangeable with a colon.
Good catching, but
In R 4.3.0 on FreeBSD, the same error after changing the period to a colon:
> as.POSIXct("1970-01-01 00:00:00 UTC")
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
I copy the code from a web page. It works in R 4.3.0 on Windows and R
4.1.2 on an old CentOS.
Best,
Jinsong
On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao <jszhao at yeah.net> wrote:
Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error.
as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS.
as.POSIXct("1970-01-01 00:00.00 UTC")
[1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone:
Sys.timezone()
[1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 2023/5/11 17:22, Ivan Krylov wrote:
? Thu, 11 May 2023 16:56:41 +0800 Jinsong Zhao <jszhao at yeah.net> ?????:
When I run the following code in R 4.3.0 on FreeBSD, I got error.
> as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
Do strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') and
strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') both return NA for
you on FreeBSD? If not, can you trace the execution using R's debugger
to see which parts are returned as NA, failing the test in
as.POSIXlt.character?
Both codes do not return NA on FreeBSD:
> strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '')
[1] "1970-01-01 CST"
> strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '')
[1] "1970-01-01 CST"
I do not know how to use R's debugger...
I think that strptime() should have discarded the trailing parts of the string and matched at least the beginning (though not the ".00 UTC" part because it doesn't correspond to the formats tried by strptime()). Moreover, there shouldn't be significant difference between the platforms, because R seems to always use an internal implementation of strptime(). Are you using a multi-byte locale? (What's your sessionInfo() on both a system where it works and the system where it fails?)
The sessionInfo on FreeBSD said: tzcode source: system (FreeBSD) But on Windows it said: tzcode source: internal Could it be because of this? The sessionInfo on FreeBSD is: > sessionInfo() R version 4.3.0 (2023-04-21) Platform: amd64-portbld-freebsd13.1 (64-bit) Running under: FreeBSD xw6600 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64 Matrix products: default LAPACK: /usr/local/lib/R/lib/libRlapack.so.4.3.0; LAPACK version 3.11.0 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: Asia/Shanghai tzcode source: system (FreeBSD) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 The sessionInfo on Windows is: > sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621) Matrix products: default locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 [2] LC_CTYPE=Chinese (Simplified)_China.utf8 [3] LC_MONETARY=Chinese (Simplified)_China.utf8 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.utf8 time zone: Asia/Shanghai tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 > The sessionInfo on CentOS is: > sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) Matrix products: default BLAS: /home/jszhao/software/lib64/R/lib/libRblas.so LAPACK: /home/jszhao/software/lib64/R/lib/libRlapack.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.1.2 >
The origin of this problem is when I try to update rstan package in R 4.3.0 on FreeBSD. I get the same error as that https://github.com/stan-dev/rstan/issues/612 However, I did not encounter this problem when using R 4.2.x or 4.1.x on FreeBSD. Best, Jinsong
On 2023/5/11 16:56, Jinsong Zhao wrote:
Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error.
> as.POSIXct("1970-01-01 00:00.00 UTC")
Error in as.POSIXlt.character(x, tz, ...) : ? character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS.
> as.POSIXct("1970-01-01 00:00.00 UTC")
[1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone:
> Sys.timezone()
[1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong
? Thu, 11 May 2023 17:51:33 +0800 Jinsong Zhao <jszhao at yeah.net> ?????:
Both codes do not return NA on FreeBSD:
> strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '')
[1] "1970-01-01 CST"
> strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '')
[1] "1970-01-01 CST"
I must have misread the code of as.POSIXlt.character then.
I do not know how to use R's debugger...
In short, debugonce(as.POSIXlt.character) will prepare R to start the
debugger once the function is called. The debugger prompt is described
in ?browser; it's mostly like R's prompt (you can call print(variable)
and other, more complicated expressions), but there are special
commands like "n" (next statement), "s" (step inside the function call)
and so on.
Call:
debugonce(as.POSIXlt.character)
as.POSIXct("1970-01-01 00:00.00 UTC")
Use n to step over function calls and s to step inside for loops. See
what's returned by strptime() calls inside this function. It's raising
an exception because all of them contain NAs somewhere; which element is
NA? What are the exact arguments used to call strptime()?
This doesn't seem to be due to differences in locale: both CentOS and
FreeBSD use en_US.UTF-8.
Best regards, Ivan