Date functions perform date and time conversions between the calendar date and the julian date.
The calendar date is the date of the proleptic Gregorian calendar, i.e. the calendar used in most countries today where centennial years are not leap unless they are a multiple of 400. This calendar was introduced by Pope Gregory XIII on October 5, 1582 (Julian Calendar, the calendar used until then) which became October 15. The calendar used in this library is proleptic, which means the rule for leap years is applied back to the past, before its introduction. Negative years are permitted; the year 0 does exist.
The julian date is the number of days since the reference point, January 1st -4713 B.C. (Julian calendar) at noon. The fractional part corresponds to the fraction of day after noon: a fraction of 0.25, for instance, is 18:00 or 6 P.M. The julian date is used by astronomers with GMT; but using a local time zone is fine as long as an absolute time is not required.
Calendar to julian date conversion.
jd = cal2julian(datetime) jd = cal2julian(year, month, day) jd = cal2julian(year, month, day, hour, minute, second)
cal2julian(datetime) converts the calendar date and time to the julian date. Input arguments can be a vector of 3 components (year, month and day) or 6 components (date and hour, minute and seconds), or scalar values provided separately. The result of clock can be used directly.
Number of days between October 4 1967 and April 18 2005:
cal2julian(2005, 4, 18) - cal2julian(1967, 10, 4) 14624
Julian date to calendar conversion.
datetime = julian2cal(jd) (year, month, day, hour, minute, second) = julian2cal(jd)
julian2cal(jd) converts the julian date to calendar date and time. With a single output, the result is given a a row vector of 6 values for the year, month, day, hour, minute and second; with more output arguments, values are given separately.
Date 1000 days after April 18 2005:
julian2cal(cal2julian(2005, 4, 18) + 1000) 2008 1 13 0 0 0