OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
date_proc.cc File Reference
#include "config_ff.h"
#include <cassert>
#include "Error.h"
Include dependency graph for date_proc.cc:

Go to the source code of this file.

Functions

int dayofweek (double j)
 Given a Julian day number, return the day of week for that date. More...
 
int days_in_month (int year, int month)
 
double days_in_year (int year)
 How many days are in the given Gregorian year? More...
 
void days_to_month_day (int year, int ddd, int *month, int *day)
 Given the day number of the year, return the month and day of the month. More...
 
void gregorian_date (double jd, int *year, int *month, int *day, int *hours, int *minutes, double *seconds)
 Given a Julian day number, return the Gregorian date. More...
 
int is_leap (int year)
 Is the given Gregorian year a leap year? More...
 
long julian_day (int year, int month, int day)
 Given a gregorian date in year, month and day, return the Julian day number. More...
 
int month_day_to_days (int year, int month, int day)
 Given the month and day numbers, return the days since the first of the year. More...
 

Function Documentation

int dayofweek ( double  j)

Given a Julian day number, return the day of week for that date.

Returns
Day of week (0-6)

Definition at line 257 of file date_proc.cc.

int days_in_month ( int  year,
int  month 
)

Definition at line 191 of file date_proc.cc.

References is_leap().

Referenced by operator==(), and operator>=().

Here is the call graph for this function:

double days_in_year ( int  year)

How many days are in the given Gregorian year?

Returns
The number of days, as a double.

Definition at line 59 of file date_proc.cc.

References is_leap().

Referenced by DODS_Date::fraction(), and DODS_Date_Time::get().

Here is the call graph for this function:

void days_to_month_day ( int  year,
int  ddd,
int *  month,
int *  day 
)

Given the day number of the year, return the month and day of the month.

Parameters
yearThe year.
dddThe day of the year (ones-based).
monthThe correcponding month of the year (ones-based value-result parameter).
dayThe day of the month (ones-based value-result parameter).
Returns
void.

Definition at line 238 of file date_proc.cc.

References assert, and is_leap().

Referenced by DODS_Date::set().

Here is the call graph for this function:

void gregorian_date ( double  jd,
int *  year,
int *  month,
int *  day,
int *  hours,
int *  minutes,
double *  seconds 
)

Given a Julian day number, return the Gregorian date.

The Julian day number is passed as a double while the gregorian date is returned using six `value-result' parameters:

See also
Algorithm 199 in Collected algorithms of the CACM Author: Robert G. Tantzen, Translator: Nat Howard
Parameters
jdThe Julian date to convert.
yearThe year fully-qualified (1977 is `1977' not 77, `77' is 77 A.D.)
monthThe month. Ones-based.
dayThe day.
hoursThe hour. zero-based.
minutesThe minutes. zero-based.
secondsThe seconds. zero-based.
Returns
void

Definition at line 121 of file date_proc.cc.

References assert, and L.

int is_leap ( int  year)

Is the given Gregorian year a leap year?

Returns
1 if the year is a leap year, otherwise return 0.

Definition at line 52 of file date_proc.cc.

Referenced by days_in_month(), days_in_year(), and days_to_month_day().

long julian_day ( int  year,
int  month,
int  day 
)

Given a gregorian date in year, month and day, return the Julian day number.

NB: I am not sure this code deals correctly with dates before 1100 A.D.

Parameters
yearThe year. Must be A.D. and `fully qualified'
monthThe month. Ones-based month number (Jan = 1, Dec = 12).
dayThe day. Ones-based day number.
See also
ACM Collected algorithms.
Returns
The Julian day number.

Definition at line 86 of file date_proc.cc.

References L.

Referenced by operator<=(), operator==(), and operator>=().

int month_day_to_days ( int  year,
int  month,
int  day 
)

Given the month and day numbers, return the days since the first of the year.

Parameters
yearThe year.
monthThe month of the year.
dayThe days of the month.
Returns
The days since the first of the year (ones-based).

Definition at line 169 of file date_proc.cc.

Referenced by DODS_Date::set().