surveillance (version 1.12.1)

isoWeekYear: Find ISO week and ISO year of a vector of Date objects on Windows

Description

This function extracts the ISO week and ISO year of a Date according to the ISO 8601 specification. Note that this function does nothing else than format.Date(x, "%G") and format.Date(x, "%V") would do on Mac/Unix computers. However, this is not implemented on Windows.

A small internal wrapper for format.Date (called formatDate) thus directs all calls having one of these format strings to this function, if the .Platform$OS.type information reveals a Windows system. The function also provides three additional strptime formatting strings: "%Q" (the quarter of a date as a numeric), " (day within the quarter). These are, e.g., used by linelist2sts.

Usage

isoWeekYear(Y, M=NULL, D=NULL)

Arguments

Y
Date object (POSIX) or the year. Can be a vector.
M
month, NULL if Y is a Date object)
D
day, NULL if Y is a Date object)

Value

  • A list with entries ISOYear and ISOWeek containing the corresponding results.

Details

The code to find the ISO week and year on Windows is by Gustaf Rydevik posted at http://tolstoy.newcastle.edu.au/R/e10/help/10/05/5588.html

Examples

Run this code
dates <- as.Date(c("2002-12-31","2003-01-01","2003-01-06"))
isoWeekYear(dates)

Run the code above in your browser using DataLab