Rev 78418 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R Under development (unstable) (2020-05-18 r78485) -- "Unsuffered Consequences"Copyright (C) 2020 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type 'license()' or 'licence()' for distribution details.R is a collaborative project with many contributors.Type 'contributors()' for more information and'citation()' on how to cite R or R packages in publications.Type 'demo()' for some demos, 'help()' for on-line help, or'help.start()' for an HTML browser interface to help.Type 'q()' to quit R.> #### Test R's (64-bit) date-time functions .. output tested *sloppily*>> ## R's internal fixes are used on 32-bit platforms.> ## macOS gets these wrong: see HAVE_WORKING_64BIT_MKTIME>> Sys.setenv(TZ = "UTC")> (z <- as.POSIXct("1848-01-01 12:00"))[1] "1848-01-01 12:00:00 UTC"> c(unclass(z))[1] -3849940800> (z <- as.POSIXct("2040-01-01 12:00"))[1] "2040-01-01 12:00:00 UTC"> c(unclass(z))[1] 2209032000> (z <- as.POSIXct("2040-07-01 12:00"))[1] "2040-07-01 12:00:00 UTC"> c(unclass(z))[1] 2224756800>> Sys.setenv(TZ = "Europe/London") # pretty much portable.> (z <- as.POSIXct("1848-01-01 12:00"))[1] "1848-01-01 12:00:00 GMT"> c(unclass(z))[1] -3849940800> ## We don't know the operation of timezones next year let alone in 2040> ## but these should at least round-trip> ## These got the wrong timezone on Linux with glibc 2.2[67]> as.POSIXct("2040-01-01 12:00")[1] "2040-01-01 12:00:00 GMT"> as.POSIXct("2040-07-01 12:00")[1] "2040-07-01 12:00:00 BST">> Sys.setenv(TZ = "EST5EDT") # also pretty much portable.> (z <- as.POSIXct("1848-01-01 12:00"))[1] "1848-01-01 12:00:00 EST"> c(unclass(z))[1] -3849922800> ## see comment above> as.POSIXct("2040-01-01 12:00")[1] "2040-01-01 12:00:00 EST"> as.POSIXct("2040-07-01 12:00")[1] "2040-07-01 12:00:00 EDT">> ## PR15613: had day as > 24hrs.> as.POSIXlt(ISOdate(2071,1,13,0,0,tz="Etc/GMT-1"))$wday[1] 2> as.POSIXlt(ISOdate(2071,1,13,0,1,tz="Etc/GMT-1"))$wday[1] 2>>> ## Incorrect use of %b should work even though abbreviation does match> Sys.setlocale("LC_TIME", "C") # to be sure[1] "C"> stopifnot(!is.na(strptime("11-August-1903", "%d-%b-%Y")))>> ## Prior to R 4.0.0 this oveflowed an array. Now gives a warning>> z <- paste("2017", c(1,365,366), sep = "-")> (zz <- strptime(z, "%Y-%j"))[1] "2017-01-01 EST" "2017-12-31 EST" NAWarning message:In strptime(z, "%Y-%j") : day-of-year 366 in year 2017 is invalid> stopifnot(identical(is.na(zz), c(FALSE, FALSE, TRUE)))>