1 2R version 4.1.0 Patched (2021-06-17 r80511) -- "Camp Pontanezen" 3Copyright (C) 2021 The R Foundation for Statistical Computing 4Platform: x86_64-pc-linux-gnu (64-bit) 5 6R is free software and comes with ABSOLUTELY NO WARRANTY. 7You are welcome to redistribute it under certain conditions. 8Type 'license()' or 'licence()' for distribution details. 9 10R is a collaborative project with many contributors. 11Type 'contributors()' for more information and 12'citation()' on how to cite R or R packages in publications. 13 14Type 'demo()' for some demos, 'help()' for on-line help, or 15'help.start()' for an HTML browser interface to help. 16Type 'q()' to quit R. 17 18> #### Test R's (64-bit) date-time functions .. output tested *sloppily* 19> 20> ## R's internal fixes are used on 32-bit platforms. 21> ## macOS gets these wrong: see HAVE_WORKING_64BIT_MKTIME 22> 23> Sys.setenv(TZ = "UTC") 24> (z <- as.POSIXct("1848-01-01 12:00")) 25[1] "1848-01-01 12:00:00 UTC" 26> c(unclass(z)) 27[1] -3849940800 28> (z <- as.POSIXct("2040-01-01 12:00")) 29[1] "2040-01-01 12:00:00 UTC" 30> c(unclass(z)) 31[1] 2209032000 32> (z <- as.POSIXct("2040-07-01 12:00")) 33[1] "2040-07-01 12:00:00 UTC" 34> c(unclass(z)) 35[1] 2224756800 36> 37> Sys.setenv(TZ = "Europe/London") # pretty much portable. 38> (z <- as.POSIXct("1848-01-01 12:00")) 39[1] "1848-01-01 12:00:00 GMT" 40> c(unclass(z)) 41[1] -3849940800 42> ## We don't know the operation of timezones next year let alone in 2040 43> ## but these should at least round-trip 44> ## These got the wrong timezone on Linux with glibc 2.2[67] 45> as.POSIXct("2040-01-01 12:00") 46[1] "2040-01-01 12:00:00 GMT" 47> as.POSIXct("2040-07-01 12:00") 48[1] "2040-07-01 12:00:00 BST" 49> 50> Sys.setenv(TZ = "EST5EDT") # also pretty much portable. 51> (z <- as.POSIXct("1848-01-01 12:00")) 52[1] "1848-01-01 12:00:00 EST" 53> c(unclass(z)) 54[1] -3849922800 55> ## see comment above 56> as.POSIXct("2040-01-01 12:00") 57[1] "2040-01-01 12:00:00 EST" 58> as.POSIXct("2040-07-01 12:00") 59[1] "2040-07-01 12:00:00 EDT" 60> 61> ## PR15613: had day as > 24hrs. 62> as.POSIXlt(ISOdate(2071,1,13,0,0,tz="Etc/GMT-1"))$wday 63[1] 2 64> as.POSIXlt(ISOdate(2071,1,13,0,1,tz="Etc/GMT-1"))$wday 65[1] 2 66> 67> 68> ## Incorrect use of %b should work even though abbreviation does match 69> Sys.setlocale("LC_TIME", "C") # to be sure 70[1] "C" 71> stopifnot(!is.na(strptime("11-August-1903", "%d-%b-%Y"))) 72> 73> ## Prior to R 4.0.0 this oveflowed an array. Now gives a warning 74> 75> z <- paste("2017", c(1,365,366), sep = "-") 76> (zz <- strptime(z, "%Y-%j")) 77[1] "2017-01-01 EST" "2017-12-31 EST" NA 78Warning message: 79In strptime(z, "%Y-%j") : day-of-year 366 in year 2017 is invalid 80> stopifnot(identical(is.na(zz), c(FALSE, FALSE, TRUE))) 81> 82