Learn R Programming

oce (version 0.9-14)

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", "argo",
                          "sas", "spss", "yearday"), 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. Argo times, indicated by type="argo", are measured in days since the start of the twentieth century. SAS times, indicated by type="sas", have origin at the start of 1960. SPSS times, indicated by type="spss", have origin at 1582-10-14. Note that in these cases, t is a vector. In the yearday and GPS cases, however, t must be a two-column matrix. For type="gps", 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). For type="yearday", the first column is the year, and the second is the yearday (starting at 1 for the first second of January 1, to match the convention used by Sea-Bird CTD software).

See Also

numberAsHMS

Examples

Run this code
numberAsPOSIXct(0)                     # unix time 0
numberAsPOSIXct(1, type="matlab")      # matlab time 1
numberAsPOSIXct(cbind(566,345615), type="gps") # Canada Day
numberAsPOSIXct(cbind(2013, 0), type="yearday") # start of 2013

Run the code above in your browser using DataLab