Learn R Programming

oce (version 0.2-1)

numberAsPOSIXct: Convert a numeric time to a POSIXct time

Description

Convert a numeric time to a POSIXct time

Usage

numberAsPOSIXct(t, type=c("unix", "matlab", "gps"), tz="UTC")

Arguments

t
an integer corresponding to a time, in a way that depends on type (see Details).
type
the type of time (see Details).
tz
a string indicating the time zone, used only for unix and matlab times, since GPS times are always referenced to the UTC timezone.

Value

Details

Unix times, indicated by type="unix", are measured in seconds since the start of the year 1970. Matlab times, indicated by type="matlab", are measured in years since the start of the year 1899. Thus, in both cases, t is a vector. However, for type="gps", t is a two-column matrix, in which the first column is the GPS "week" (referenced to 1999-08-22) and the second column is GPS "second" (i.e. the second within the week).

Examples

Run this code
cat("In Unix, time=0 (seconds) means ", format(numberAsPOSIXct(0)), "")
cat("In Matlab, time=1 (days) means ", format(numberAsPOSIXct(1, type="matlab")), "")
cat("Canada Day 2001 was", format(numberAsPOSIXct(cbind(566,345615), type="gps")), "")

Run the code above in your browser using DataLab