datetimes {ssBase}R Documentation

Calculate Dates and Times

Description

Calculates the number of days and fractions thereof from the 1 January 1970.

Usage

datetimes(year, month, day, hour, minute, second=0, dp.second=NA,
          missing = FALSE)

Arguments

year an integer, e.g. 1998.
month an integer with values 1, 2, ..., 12.
day an integer giving the day of the month, e.g. 1, 2, ..., 31.
hour an integer giving the hour of the day, i.e. 0, 1, 2, ..., 23.
minute an integer giving the minute of the hour, i.e. 0, 1, 2, ..., 59.
second a numeric vector giving the seconds, e.g. 32.45. The number of decimal places should be consistent with dp.second below. Default is zero.
dp.second an integer giving the number of decimal places specified in second. Default is NA, i.e. not specified. In this case zero is used in all calculations.
missing logical, default is FALSE. Indicates whether information about the extent of missing values should be passed out of the function.

Value

If missing == FALSE, then only a datetimes object is returned. If TRUE, a list object which contains a datetimes object called ti and an object called missing is returned.
A datetimes object is a numeric vector with class "datetimes", and values for each date that are the number of days and fractions thereof from 00:00:00hrs on 1 January 1970. This object also has attributes "origin" which species the origin date, and "dp.second" which specifies the accuracy of the variable second. This information will determine the number of decimal places used to print the object. By default, the object will be printed in the format DDMMMYYYY hh:mm:ss.s, where the number of decimal places is specified as above.
The vector missing is character, taking values "Y", "M", "D", "h", "m", "s", corresponding to whether the year, month, day, hour, minute or second is missing, respectively. Where more than one of these values are missing then missing takes the first one from c("Y", "M", "D", "h", "m", "s"). When month or day is missing, one is used in calculations; and where hour, minute or second are missing, zero is used in calculations.
The main difference with the chron function in package chron is that the datetimes function has a facility to account for fractional seconds, and also missing values as described above.

See Also

format.datetimes, [.datetimes, print.datetimes, years1, months1, days1

Examples

a <- datetimes(1998, 6, 2, 13, 34, 25.9, dp.second=1)
print(a)
print.default(a)
format(a)

[Package ssBase version 2.2-1 Index]