Buglet in handling times in R-3.5.1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Buglet in handling times in R-3.5.1

g.russell-2
Dear R developers,

I have found a minute bug in R-3.5.1 (Windows version), about how times not an exact number of seconds are displayed.
> as.POSIXct("1969-01-01 01:00")+0.3
[1] "1969-01-01 01:00:01 CET"
> as.POSIXct("1970-01-01 01:00")+0.3
[1] "1970-01-01 01:00:00 CET"

So for 1969, adding 0.3 of a second means you round UP, for 1970 you round DOWN. But I think it should be consistent.

At the end of this message I have put the usual version information.

Thanks for all your help and for your work on this wonderful product.


> R.version
               _
platform       x86_64-w64-mingw32
arch           x86_64
os             mingw32
system         x86_64, mingw32
status
major          3
minor          5.1
year           2018
month          07
day            02
svn rev        74947
language       R
version.string R version 3.5.1 (2018-07-02)
nickname       Feather Spray

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Buglet in handling times in R-3.5.1

Emil
Here on my Mac it looks worse: not a rounding difference, but an off-by-one error for fractional seconds before 1970, looks like the conversion to POSIXlt is doing something wrong:

Options(digits=12)
as.numeric(as.POSIXlt(as.POSIXct('1969-01-01')))
[1] -31539600
# As expected
as.numeric(as.POSIXlt(as.POSIXct('1969-01-01')+.1))
[1] -31539598.9
# An additional second disappears (and no, there was no (negative) leap second)

I'm not enough at home in C to get to the core of it, the problem is in the .Internal call
Hoping somebody can investigate further.
Specs: R 3.5.1; macOS 10.13.6

Best regards,
Emil Bode
 

On 09/10/2018, 17:27, "R-devel on behalf of Russell, George" <[hidden email] on behalf of [hidden email]> wrote:

    Dear R developers,
   
    I have found a minute bug in R-3.5.1 (Windows version), about how times not an exact number of seconds are displayed.
    > as.POSIXct("1969-01-01 01:00")+0.3
    [1] "1969-01-01 01:00:01 CET"
    > as.POSIXct("1970-01-01 01:00")+0.3
    [1] "1970-01-01 01:00:00 CET"
   
    So for 1969, adding 0.3 of a second means you round UP, for 1970 you round DOWN. But I think it should be consistent.
   
    At the end of this message I have put the usual version information.
   
    Thanks for all your help and for your work on this wonderful product.
   
   
    > R.version
                   _
    platform       x86_64-w64-mingw32
    arch           x86_64
    os             mingw32
    system         x86_64, mingw32
    status
    major          3
    minor          5.1
    year           2018
    month          07
    day            02
    svn rev        74947
    language       R
    version.string R version 3.5.1 (2018-07-02)
    nickname       Feather Spray
   
    ______________________________________________
    [hidden email] mailing list
    https://stat.ethz.ch/mailman/listinfo/r-devel
   

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Buglet in handling times in R-3.5.1

Marco atzeri
In reply to this post by g.russell-2
Am 09.10.2018 um 16:56 schrieb Russell, George:
> Dear R developers,
>
> I have found a minute bug in R-3.5.1 (Windows version), about how times not an exact number of seconds are displayed.
>> as.POSIXct("1969-01-01 01:00")+0.3
> [1] "1969-01-01 01:00:01 CET"
>> as.POSIXct("1970-01-01 01:00")+0.3
> [1] "1970-01-01 01:00:00 CET"
>
> So for 1969, adding 0.3 of a second means you round UP, for 1970 you round DOWN. But I think it should be consistent.

More likely a bug in the underlining C library
The Cygwin build does not show the problem

 > as.numeric(as.POSIXct("1969-01-01 01:00")+0.3)
[1] -31535999.7
 > as.POSIXct("1969-01-01 01:00")+0.3
[1] "1969-01-01 01:00:00 CET"
 > as.numeric(as.POSIXct("1969-01-01 01:00"))
[1] -31536000
 > as.POSIXct("1969-01-01 01:00")
[1] "1969-01-01 01:00:00 CET"

 > R.version
                _
platform       x86_64-unknown-cygwin
arch           x86_64
os             cygwin
system         x86_64, cygwin
status
major          3
minor          5.1
year           2018
month          07
day            02
svn rev        74947
language       R
version.string R version 3.5.1 (2018-07-02)
nickname       Feather Spray


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel