SuperNOVAS v1.3
The NOVAS C library, made better
Loading...
Searching...
No Matches
calendar.c File Reference

Functions

int cal_date (double tjd, short *restrict year, short *restrict month, short *restrict day, double *restrict hour)
 
double julian_date (short year, short month, short day, double hour)
 
double novas_jd_from_date (enum novas_calendar_type calendar, int year, int month, int day, double hour)
 
int novas_jd_to_date (double tjd, enum novas_calendar_type calendar, int *restrict year, int *restrict month, int *restrict day, double *restrict hour)
 

Detailed Description

Date
Created on Mar 6, 2025
Author
Attila Kovacs and G. Kaplan

Various functions to convert between calendar date and Julian days.

Function Documentation

◆ cal_date()

int cal_date ( double  tjd,
short *restrict  year,
short *restrict  month,
short *restrict  day,
double *restrict  hour 
)

This function will compute a broken down date on the astronomical calendar for given the Julian day input. Input Julian day can be based on any UT-like time scale (UTC, UT1, TT, etc.) - output time value will have same basis.

NOTES:

  1. The Gregorian calendar was introduced on 15 October 1582 only (corresponding to 5 October of the previously used Julian calendar). Prior to it this function returns Julian/Roman calendar dates, e.g. the day before the reform is 1582 October 4. You can use novas_id_to_calendar() instead to convert JD days to dates in specific calendars.

  2. B.C. dates are indicated with years <=0 according to the astronomical and ISO 8601 convention, i.e., X B.C. as (1-X), so 45 B.C. as -44.

REFERENCES:

  1. Fliegel, H. & Van Flandern, T. Comm. of the ACM, Vol. 11, No. 10, October 1968, p. 657.15 October 1582
Parameters
tjd[day] Julian date
[out]year[yr] Astronomical calendar year. It may be NULL if not required. B.C. years are represented as <=0, i.e. 1 B.C. as 0 and X B.C. as (1 - X)
[out]month[month] Astronomical calendar month [1:12]. It may be NULL if not required.
[out]day[day] Day of the month [1:31]. It may be NULL if not required.
[out]hour[h] Hour of day [0:24]. It may be NULL if not required.
Returns
0
See also
novas_jd_to_date()
novas_jd_from_date()
get_utc_to_tt()
get_ut1_to_tt()
tt2tdb()

References NOVAS_ASTRONOMICAL_CALENDAR, and novas_jd_to_date().

◆ julian_date()

double julian_date ( short  year,
short  month,
short  day,
double  hour 
)

Returns the Julian day for a given astronomical calendar date. Input time value can be based on any UT-like time scale (UTC, UT1, TT, etc.) - output Julian day will have the same basis.

NOTES:

  1. The Gregorian calendar was introduced on 1582 October 15 only. Prior to that, astronomical dates are Julian/Roman dates, so the day before the reform was 1582 October 4. You can also use novas_jd_from_date() to convert dates with more flexibility.

  2. B.C. dates are indicated with years <=0 according to the astronomical and ISO 8601 convention, i.e., X B.C. as (1-X), so 45 B.C. as -44.

  3. Added argument range checking in v1.3.0, returning NAN if the month or day are out of the normal range (for a leap year).

REFERENCES:

  1. Fliegel, H. & Van Flandern, T. Comm. of the ACM, Vol. 11, No. 10, October 1968, p. 657.
Parameters
year[yr] Astronomical calendar year. B.C. years can be simply represented as <=0, e.g. 1 B.C. as 0, and X B.C. as (1 - X).
month[month] Astronomical calendar month [1:12]
day[day] Astronomical day of month [1:31]
hour[hr] Hour of day [0:24]
Returns
[day] the fractional Julian date for the input calendar date, ot NAN if month or day components are out of range.
See also
novas_jd_from_date()
novas_jd_to_date()
get_utc_to_tt()
get_ut1_to_tt()
tt2tdb()

References NOVAS_ASTRONOMICAL_CALENDAR, and novas_jd_from_date().

◆ novas_jd_from_date()

double novas_jd_from_date ( enum novas_calendar_type  calendar,
int  year,
int  month,
int  day,
double  hour 
)

Returns the Julian day for a given calendar date. Input time value can be based on any astronomical time scale (UTC, UT1, TT, etc.) - output Julian date will have the same basis.

The input date is the conventional calendar date, affected by the Gregorian calendar reform of 1582. Thus, the input date is for the Gregorian calendar for dates starting 15 October 1582, and for the Julian (Roman) calendar (introduced in 45 B.C.) for dates prior to that.

NOTES:

  1. B.C. dates are indicated with years <=0 according to the astronomical and ISO 8601 convention, i.e., X B.C. as (1-X), so 45 B.C. as -44.

  2. Added argument range checking in v1.3.0, returning NAN if the month or day are out of the normal range (for a leap year).

REFERENCES:

  1. Fliegel, H. & Van Flandern, T. Comm. of the ACM, Vol. 11, No. 10, October 1968, p. 657.
Parameters
calendarThe type of calendar to use: NOVAS_ASTRONOMICAL_CALENDAR, NOVAS_GREGORIAN_CALENDAR, or NOVAS_ROMAN_CALENDAR.
year[yr] Calendar year. B.C. years can be simply represented as negative years, e.g. 1 B.C. as -1.
month[month] Calendar month [1:12]
day[day] Day of month [1:31]
hour[hr] Hour of day [0:24]
Returns
[day] the fractional Julian day for the input calendar date, ot NAN if month or day components are out of range.
Since
1.3
Author
Attila Kovacs
See also
novas_jd_to_date()
get_utc_to_tt()
get_ut1_to_tt()
tt2tdb()

References NOVAS_ASTRONOMICAL_CALENDAR, NOVAS_GREGORIAN_CALENDAR, NOVAS_JD_START_GREGORIAN, and NOVAS_ROMAN_CALENDAR.

◆ novas_jd_to_date()

int novas_jd_to_date ( double  tjd,
enum novas_calendar_type  calendar,
int *restrict  year,
int *restrict  month,
int *restrict  day,
double *restrict  hour 
)

This function will compute a broken down date on the specified calendar for given the Julian day input. Input Julian day can be based on any astronomical time scale (UTC, UT1, TT, etc.) - output time value will have same basis.

NOTES:

  1. B.C. dates are indicated with years <=0 according to the astronomical and ISO 8601 convention, i.e., X B.C. as (1-X), so 45 B.C. as -44.

REFERENCES:

  1. Fliegel, H. & Van Flandern, T. Comm. of the ACM, Vol. 11, No. 10, October 1968, p. 657.
Parameters
tjd[day] Julian day.
calendarThe type of calendar to use: NOVAS_ASTRONOMICAL_CALENDAR, NOVAS_GREGORIAN_CALENDAR, or NOVAS_ROMAN_CALENDAR.
[out]year[yr] Calendar year. B.C. years are represented as negative values, e.g. -1 corresponds to 1 B.C. It may be NULL if not required.
[out]month[month] Calendar month [1:12]. It may be NULL if not required.
[out]day[day] Day of the month [1:31]. It may be NULL if not required.
[out]hour[h] Hour of day [0:24]. It may be NULL if not required.
Returns
0
Since
1.3
Author
Attila Kovacs
See also
novas_jd_from_date()
get_utc_to_tt()
get_ut1_to_tt()
tt2tdb()

References NOVAS_ASTRONOMICAL_CALENDAR, NOVAS_GREGORIAN_CALENDAR, NOVAS_JD_START_GREGORIAN, and NOVAS_ROMAN_CALENDAR.