/usr/lib/R/site-library/gdata/unitTests/runit.getDateTimeParts.R is in r-cran-gdata 2.13.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ### runit.getDateTimeParts.R
###------------------------------------------------------------------------
### What: Extract date and time parts from ... - unit tests
### $Id$
### Time-stamp: <2008-12-30 22:41:18 ggorjan>
###------------------------------------------------------------------------
### {{{ --- Test setup ---
if(FALSE) {
library("RUnit")
library("gdata")
}
num <- 1
cha <- "a"
fac <- factor(c("A"))
tYear <- as.character(c(2006, 1995, 1005, 3067))
tMonth <- c("01", "04", "06", "12")
tDay <- c("01", "12", "22", "04")
tDate <- paste( paste(tYear, tMonth, tDay, sep="-"), "GMT" )
tHour <- c("05", "16", "20", "03")
tMin <- c("16", "40", "06", "52")
tSec <- c("56", "34", "05", "15")
tTime <- paste(tHour, tMin, tSec, sep=":")
cDate <- as.Date(tDate)
cDatePOSIXct <- as.POSIXct(tDate)
cDatePOSIXlt <- as.POSIXlt(tDate)
### }}}
### {{{ --- getYear ---
test.getYear <- function()
{
checkException(getYear(x=num))
checkException(getYear(x=cha))
checkException(getYear(x=fac))
checkIdentical(getYear(x=cDate), tYear)
checkIdentical(getYear(x=cDatePOSIXct), tYear)
checkIdentical(getYear(x=cDatePOSIXlt), tYear)
}
### }}}
### {{{ --- getMonth ---
test.getMonth <- function()
{
checkException(getMonth(x=num))
checkException(getMonth(x=cha))
checkException(getMonth(x=fac))
checkIdentical(getMonth(x=cDate), tMonth)
checkIdentical(getMonth(x=cDatePOSIXct), tMonth)
checkIdentical(getMonth(x=cDatePOSIXlt), tMonth)
}
### }}}
### {{{ --- getDay ---
test.getDay <- function()
{
checkException(getDay(x=num))
checkException(getDay(x=cha))
checkException(getDay(x=fac))
checkIdentical(getDay(x=cDate), tDay)
checkIdentical(getDay(x=cDatePOSIXct), tDay)
checkIdentical(getDay(x=cDatePOSIXlt), tDay)
}
### }}}
### {{{ --- getHour ---
test.getHour <- function()
{
checkException(getHour(x=num))
checkException(getHour(x=cha))
checkException(getHour(x=fac))
## checkIdentical(getHour(x=cDate), tHour)
}
### }}}
### {{{ --- getMin ---
test.getMin <- function()
{
checkException(getMin(x=num))
checkException(getMin(x=cha))
checkException(getMin(x=fac))
## checkIdentical(getMin(x=cDate), tMin)
}
### }}}
### {{{ --- getSec ---
test.getSec <- function()
{
checkException(getSec(x=num))
checkException(getSec(x=cha))
checkException(getSec(x=fac))
## checkIdentical(getSec(x=cDate), tSec)
}
### }}}
### {{{ Dear Emacs
### Local variables:
### folded-file: t
### end:
### }}}
###------------------------------------------------------------------------
### runit.getDateTimeParts.R ends here
|