Learn R Programming

eseis (version 0.6.0)

time_convert: Convert Julian Day to Date and vice versa

Description

The function converts a Julian Day value to a date, to POSIXct if a year is provided, otherwise to POSIXlt.

Usage

time_convert(input, output, timezone = "UTC", year)

Value

Numeric vector,

Arguments

input

Numeric vector, input time Supported formats are YYYY-MM-DD, JD and POSIXct.

output

Numeric vector, output time. Supported formats are YYYY-MM-DD, JD and POSIXct.

timezone

Character vector, time zone of the output date. Default is "UTC".

year

Character vector, year of the date. Only used when input is JD. If omitted, the current year is used.

Author

Michael Dietze

Examples

Run this code

## convert Julian Day 18 to POSIXct
time_convert(input = 18, output = "POSIXct")

## convert Julian Day 18 to yyyy-mm-dd
time_convert(input = 18, output = "yyyy-mm-dd")

## convert yyyy-mm-dd to Julian Day
time_convert(input = "2016-01-18", output = "JD")

## convert a vector of Julian Days to yyyy-mm-dd
time_convert(input = 18:21, output = "yyyy-mm-dd")
                     

Run the code above in your browser using DataLab