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
>