replaceDate: replace elements of a string with date and time elements

replaceDateR Documentation

replace elements of a string with date and time elements

Description

Replace elements of a string with date and time elements.

Usage

replaceDate(string=NULL, date.str=NULL, format = "%Y-%m-%d %H:%M:%S")

Arguments

string

a string with the elements to replace with the date and time elements. For example, if the string "yyyy/yyyymmdd" is provided then yyyy will be replaced with the year, mm with the month and dd with the day. Legend: yyyy year; mm month; dd day; hh hour.

date

a date-time string, such as for example "2017.01.01"

format

the format to be used for the output string. For the list of items see the help page of strptime

Details

These functions invoke the function str2Rdate and the built-in functions formatC, as.POSIXlt, gsub and strptime.

Value

str2Rdate: a string of the same lenght as the input string where the elements yyyy,mm,dd,hh have been replaced by the date-time elements.

Author(s)

Cristian Lussana

See Also

year, month, day

Examples

a <- replaceDate("yyyymm/hello_yyyymmdd.txt","2017.01.01.12","%Y.%m.%d.%H")


metno/gibson documentation built on Feb. 12, 2024, 7:25 a.m.