time_convert function

Convert Julian Day to Date and vice versa

Convert Julian Day to Date and vice versa

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

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

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.

Returns

Numeric vector,

Examples

## 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")

Author(s)

Michael Dietze

  • Maintainer: Michael Dietze
  • License: GPL-3
  • Last published: 2025-03-25

Useful links