format_caaqs_dt: Format date-times in raw air quality data.

View source: R/dates.R

format_caaqs_dtR Documentation

Format date-times in raw air quality data.

Description

Intended for use with hourly air quality readings. Ensures that the date/times are in class POSIXct in the correct timezone, and ensures that the timestamp is associated with the previous hour as dictated in caaqs guidance manual.

Usage

format_caaqs_dt(
  x,
  format = "%Y-%m-%d %H:%M:%S",
  prev_hour = TRUE,
  tz = getOption("rcaaqs.timezone", default = "Etc/GMT+8")
)

Arguments

x

Vector of date-times as character or POSIXlt/ct.

format

The format of the character dates

prev_hour

Should the timestamp be assigned to the previous hour as dictated by the CAAQS guidance document? Default TRUE. This is accomplished by subtracting one second off the times.

tz

The timezone of the date-times. See Details below.

Details

You can set the timezone that you are working with in two different ways. You can set it globally with: options("rcaaqs.timezone" = "your_timezone") or set it each time you call the function by setting the tz argument to "your_timezone" where "your_timezone" is a valid timezone - see OlsonNames(). The default (when options("rcaaqs.timezone") is unset) is "Etc/GMT+8", which is equivalent to Pacific Standard Time, but does not use Daylight Savings (i.e., is GMT+8 all year). This is the standard for Air Quality Monitoring in British Columbia.

Value

POSIXct vector


bcgov/rcaaqs documentation built on Dec. 12, 2023, 9:21 a.m.