R: Convert UTC Referenced Dates Into Temporal Amounts

utinvcal.nc {RNetCDF} | R Documentation

## Convert UTC Referenced Dates Into Temporal Amounts

### Description

Convert a UTC referenced date into a temporal amount.

### Usage

    utinvcal.nc(unitstring, value)

### Arguments

`unitstring` | A temporal unit with an origin (e.g., “days since 1900-01-01”).
`value` | Dates to convert as a numeric vector or array, or a vector of strings or POSIXct values.

### Details

Uses the UDUNITS library to convert a UTC-referenced date and time into the amount, `value`, of the temporal unit, `unitstring`.

If the dates are given in string form, the structure must be exactly `"YYYY-MM-DD hh:mm:ss"`.

A vector of POSIXct values is also accepted as input. These are converted to the specified units by a linear transformation, without an intermediate separation into date components.

### Value

A vector containing the amount(s) of the temporal unit(s) corresponding to the given date(s).

### Author(s)

Pavel Michna, Milton Woods

### References

https://www.unidata.ucar.edu/software/udunits/

### See Also

`utcal.nc`

### Examples

    if (inherits(try(utcal.nc("seconds since 1970-01-01", 0)), "try-error")) {
      warning("UDUNITS calendar conversions not supported by this build of RNetCDF")

    } else {

      ##  Convert UTC referenced time to other time units
      utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(1900,1,1,5,25,0))
      utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", "1900-01-01 05:25:00")
      utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", ISOdatetime(1900,1,1,5,25,0,tz="UTC"))

    }

    ##  An example of reading and writing a netcdf time coordinate
    ##  is given in the help for utcal.nc

[Package RNetCDF version 2.4-2 Index]