setGridDates.asPOSIXlt: Set Grid dates as POSIXlt (possibly with user-defined time...

View source: R/fillGrid.R

setGridDates.asPOSIXltR Documentation

Set Grid dates as POSIXlt (possibly with user-defined time zone)

Description

Internal utility for date format conversion to POSIX.lt

Usage

setGridDates.asPOSIXlt(grid, tz = "")

Arguments

grid

Input C4R grid

tz

Time zone to be coerced to. Default to NULL, that will preserve the actual tz if defined, or leave it as undefined otherwise.

Details

The function attempts to identify the format of the grid dates and to perform an adequate conversion to POSIXlt-class, including the time zone identification.

If no tz is specified, the function tries to "guess" it from the input. Otherwise it is set to the current time zone, with a warning.

If no hour-minute-sec information is stored, the output will read 00:00:00

Value

The C4R grid with transformed dates

Author(s)

J Bedia

See Also

Other dateutils: fillGridDates(), getFirstChar(), isAlphaCharacter()

Examples

## Not run: 
library(climate4R.datasets)
data("CMIP5_Iberia_hus850.rcp85")
# Dates are represented as character string
class(getRefDates(CMIP5_Iberia_hus850.rcp85))
# Conversion to POSIXlt
a <- setGridDates.asPOSIXlt(CMIP5_Iberia_hus850.rcp85)
range(getRefDates(a))
class(getRefDates(a))
## WARNING: Forcing a time zone will change the tz attribute, but not the time
# (i.e.: it will alter the actual times):
b <- setGridDates.asPOSIXlt(CMIP5_Iberia_hus850.rcp85, tz = "Europe/Madrid")
range(getRefDates(b))
# Therefore, tz should be used ONLY when the time zone is missing or wrongly specified in the 
# input grid and we are sure about the actual TZ of our data
# It may also be used to change the representation of the time zone, e.g., changing 
# the denomination GMT to the equivalent UTC:
c <- setGridDates.asPOSIXlt(CMIP5_Iberia_hus850.rcp85, tz = "UTC")
range(getRefDates(c))

## End(Not run)

SantanderMetGroup/transformeR documentation built on Aug. 29, 2024, 6:42 a.m.