dateFormat: Converts a Date object to character data

Description Usage Arguments Details Value Author(s) Examples

View source: R/dateFormat.R

Description

Converts a Date object to character data

Usage

1
dateFormat(date, format = NULL, optimize.dups=TRUE)

Arguments

date

A vector of dates. Can be character data or some date object – anything that can be handled by dateParse()

format

A specification of the format. The default will print as "YYYY-MM-DD" under both Windows and Linux.

optimize.dups

If TRUE, internally optimize by not performing the same computation multiple times for duplicates. This does not change the return value.

Details

Unfortunately, 'format.POSIXct' does not have the same behavior on Linux and Windows. Here are a few for the difference found in 2008:

  1. Windows version does not recognize "%y" format.

  2. Windows version does not recognize width arguments like "%02d".

  3. Windows and Linux does not agree on the meaning of "%Y". Under Windows it means "%04Y"; under Linux it prints with minimal width.

This function tries to provide identical behavior under Linux and Windows and Mac. This function formats any kind of data objects to character strings with the default format "%04Y-%02m-%02d" under both Linux and Windows. It does this by choosing a system-specific default format and then calling format().

Additional format specifications are also provided:

Value

The formatted dates as a vector of character data.

Author(s)

Tony Plate

Examples

1
dateFormat(as.Date('2001-02-13'), '%Y.%02m.%02d')

TimeWarp documentation built on May 2, 2019, 11:11 a.m.