Functions to detect, when Daylight Saving Time and leap year start and finish
detectdst(object)detectleap(object)
Arguments
object: Either a zoo / xts object or a vector of dates / times in POSIXt / Date class. Note that in order for detectdst() to work correctly, your data should not have missing observations. Otherwise it might not be possible to locate, when DST happens.
Returns
List containing:
start - data frame with id (number of observation) and the respective dates, when the DST / leap year start;
end - data frame with id and dates, when DST / leap year end.
Details
The detectdst function detects, when the change for the DST starts and ends. It assumes that the frequency of data is not lower than hourly. The detectleap function does similar for the leap year, but flagging the 29th of February as a starting and to the 28th of February next year as the ending dates.
In order for the methods to work, the object needs to be of either zoo / xts or POSIXt class and should contain valid dates.
Examples
# Generate matrix with monthly dummies for a zoo objectx <- as.POSIXct("2004-01-01")+0:(365*24*8)*60*60detectdst(x)detectleap(x)