Convert local calendar date and time to a UT Julian date

Description

Place a dated field observation or historical event on the continuous UT Julian-date scale used in ephemeris calculations.

Usage

time2jd(time, timezone, calendar, verbose = F)

Arguments

time

Character vector in YYYY/MM/DD format, optionally followed by HH:MM or HH:MM:SS. Fractional seconds are accepted. Omitted clock time means midnight.

timezone

Timezone name or fixed offset; defaults to the value in skyscapeR.vars(). See Details.

calendar

Calendar: G or Gregorian, J or Julian. Defaults to the package calendar setting, initially Gregorian.

verbose

Logical; display a conversion message. Default is FALSE.

Details

Civil dates require both a calendar and a time convention to specify an instant. The function parses each supplied date and time, verifies that the calendar date exists by converting it to a Julian date and back, then applies the chosen offset or civil timezone to obtain UT. A date without a time uses local midnight. Astronomical year numbering includes year zero. An era label can also precede the month, for example "3700 BCE/06/21".

Fixed offsets may be numeric hours east of UTC (for example 5.5), or strings such as "UTC+05:30", "UTC-02" or "GMT+01". Offsets must lie between -14 and +14 hours. UTC, GMT and the empty string mean zero offset; an empty string does not select the system timezone.

Named zones listed by OlsonNames(), such as "Europe/London", use the installed timezone database for the actual Gregorian date, not a surrogate year. They are supported only for Gregorian years 1900-9999. Earlier dates require UTC or a fixed offset. For ancient-date workflows, set skyscapeR.vars(timezone="UTC") or provide timezone explicitly. The package's initial timezone remains Europe/London. Database versions may differ across systems; fixed offsets provide reproducible conversions.

Gregorian and Julian calendars are proleptic: no automatic calendar reform is applied. Astronomical year numbering is used: 0 is 1 BCE, -1 is 2 BCE. Fixed-offset input dates support years from -100000 to 100000. A timezone offset represents civil clock time, not local solar time. These functions apply clock offsets to a UT Julian day; they do not apply leap-second, UTC-to-UT1 or TT corrections. Leap-second input is rejected.

Ambiguous and nonexistent local times at clock transitions are rejected. For an ambiguous time, specify a fixed offset to identify the intended instant. Calendar dates and clock components are validated before conversion.

Value

A numeric vector of UT Julian dates, in the same order as time.

Validation

Build 2.0.9005 passed all 499 calendar, clock, era, angle and setting checks in A01. The largest discrepancy across 240 absolute Julian dates was 0.000021 seconds. See A01 validation in the technical manual.

Scientific checks

See Also

jd2time, timestring, BC.AD, skyscapeR.vars

Examples

time2jd("2000/01/01 12:00:00", "UTC") # 2451545
# A positive offset crosses into the preceding UTC year:
jd <- time2jd("2020/01/01 00:30:00", "UTC+02")
jd2time(jd, "UTC") # 2019/12/31 22:30:00
# Ancient Julian-calendar date, with an explicit fixed offset:
time2jd("-4000/06/21 06:00:00", "UTC+02", calendar="J")
# A modern date uses that year's timezone rules:
time2jd("2007/03/15 12:00:00", "America/New_York")