shift_time: Shift date-times

View source: R/shift_time.R

shift_timeR Documentation

Shift date-times

Description

Shifts date-times for selected deployments (and associated media and observations) by a specified duration. This function can be used to correct date-time issues such as incorrectly set time zones.

  • Deployments: deploymentStart and deploymentEnd are updated and timestampIssues is set to FALSE.

  • Media: timestamp is updated.

  • Observations: eventStart and eventEnd are updated.

  • Metadata (x$temporal) are updated to match the new temporal scope.

Usage

shift_time(x, deployment_id, duration)

Arguments

x

Camera Trap Data Package object, as returned by read_camtrapdp().

deployment_id

One or more deploymentIDs.

duration

Difference between the current and new date-times. Provide as a lubridate::duration() or difftime.

Value

x with shifted date-times.

See Also

Other transformation functions: merge_camtrapdp(), round_coordinates(), write_dwc(), write_eml()

Examples

# Set desired duration between current and new date-times (e.g. 4 hours earlier)
library(lubridate, warn.conflicts = FALSE)
duration(-4, units = "hours")

# Or calculate one based on two date-times
current <- ymd_hms("2024-04-01T04:00:00", tz = "UTC")
new <- ymd_hms("2024-04-01T00:00:00", tz = "UTC")
duration <- as.duration(interval(current, new))

# Shift date-times for 2 deployments
x <- example_dataset()
x_shifted <- shift_time(x, c("00a2c20d", "29b7d356"), duration)

# Inspect results
deployments(x)[, c("deploymentID", "deploymentStart", "deploymentEnd")]
deployments(x_shifted)[, c("deploymentID", "deploymentStart", "deploymentEnd")]

inbo/camtrapdp documentation built on Dec. 20, 2024, 3:31 a.m.