Go to the source code of this file.
Compounds | |
struct | DT_DATE |
struct | DT_EVENT |
Defines | |
#define | DT_INTERVAL_DAY 1 |
#define | DT_INTERVAL_MONTH 2 |
#define | DT_INTERVAL_MONTH_DOW 3 |
#define | DT_FIRST 1 |
#define | DT_SECOND 2 |
#define | DT_THIRD 3 |
#define | DT_FOURTH 4 |
#define | DT_LAST 5 |
#define | DT_SUNDAY 0 |
#define | DT_MONDAY 1 |
#define | DT_TUESDAY 2 |
#define | DT_WEDNESDAY 3 |
#define | DT_THURSDAY 4 |
#define | DT_FRIDAY 5 |
#define | DT_SATURDAY 6 |
#define | DT_DAY 10 |
#define | DT_JANUARY 1 |
#define | DT_FEBRUARY 2 |
#define | DT_MARCH 3 |
#define | DT_APRIL 4 |
#define | DT_MAY 5 |
#define | DT_JUNE 6 |
#define | DT_JULY 7 |
#define | DT_AUGUST 8 |
#define | DT_SEPTEMBER 9 |
#define | DT_OCTOBER 10 |
#define | DT_NOVEMBER 11 |
#define | DT_DECEMBER 12 |
#define | DT_LUNAR_PERIOD 29.5305882 |
#define | DT_NEWMOON_OFFSET 17.7800836001 |
#define | DT_ASCII_BUFFER_SIZE 32 |
#define | DT_NUMERIC_OUT 0x01 |
#define | DT_US_FORMAT 0x02 |
#define | DT_EUROPE_FORMAT 0x04 |
#define | DT_UNIVERSAL_FORMAT 0x08 |
#define | DT_FREE_ALL 1 |
#define | DT_FREE_NONE 2 |
#define | DT_PREV -1 |
#define | DT_NONE 0 |
#define | DT_NEXT 1 |
#define | DT_is_leap_year(x) |
#define | DT_is_leap_year_q(x) ((x)%400==0 || ((x)%100!=0 && (x)%4==0)) |
#define | DT_set_year(date,year) |
#define | DT_set_month(date,month) |
#define | DT_set_day(date,day) |
Functions | |
DT_DATE* | DT_mkdate (int year, int month, int day) |
DT_DATE* | DT_mkdate_dow (int ordinal, int dow, int month, int year) |
DT_DATE* | DT_mkdate_rata_die (long int rata_die) |
void | DT_rmdate (DT_DATE *date) |
DT_DATE* | DT_copy_date (DT_DATE *date) |
long int | DT_days_between (DT_DATE *date1, DT_DATE *date2) |
long int | DT_months_between (DT_DATE *date1, DT_DATE *date2) |
char* | DT_ascii (DT_DATE *date, unsigned long int format) |
char* | DT_ascii_r (char *buffer, int buf_size, DT_DATE *date, unsigned long int format) |
char* | DT_dow_ascii (DT_DATE *date) |
void | DT_set_date (DT_DATE *date, int year, int month, int day) |
void | DT_set_rata_die (DT_DATE *date, long int rata_die) |
int | DT_dow (DT_DATE *date) |
int | DT_year (DT_DATE *date) |
int | DT_month (DT_DATE *date) |
int | DT_day (DT_DATE *date) |
long int | DT_rata_die (DT_DATE *date) |
void | DT_add_days (DT_DATE *date, long int days) |
void | DT_add_months (DT_DATE *date, long int months) |
void | DT_find_dow_date (DT_DATE *date, int ordinal, int dow, int month) |
int | DT_days_this_month (DT_DATE *date) |
int | DT_days_this_month_q (int year, int month) |
void | DT_easter (DT_DATE *date) |
DT_EVENT* | DT_mkevent (DT_DATE *start, DT_DATE *end, long int interval) |
DT_EVENT* | DT_mkevent_monthly (DT_DATE *start, DT_DATE *end, long int interval, int day) |
DT_EVENT* | DT_mkevent_monthly_dow (DT_DATE *start, DT_DATE *end, long int interval, int ordinal, int dow) |
void | DT_rmevent (DT_EVENT *event, int freeall) |
void | DT_event_adj_rel (DT_EVENT *event, int adj) |
void | DT_event_adj_dow (DT_EVENT *event, int sign, int dow) |
void | DT_event_multiday (DT_EVENT *event, int len) |
void | DT_event_pattern (DT_EVENT *event, char *pattern) |
int | DT_is_event_today (DT_DATE *date, DT_EVENT *event) |
DT_DATE* | DT_event_next (DT_DATE *date, DT_EVENT *event) |
int | DT_cal_rows (DT_DATE *date) |
int | DT_cal_day_to_row (DT_DATE *date) |
int | DT_cal_day_to_col (DT_DATE *date) |
int | DT_cal_row_col_to_day (DT_DATE *date, int row, int col) |
double | DT_moon_age (DT_DATE *date, int timezone) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Initial value:
Determines if a date is in a leap year.
|
Determines if a year is a leap year.
|
Initial value:
DT_set_date((date),DT_year(date), \ DT_month(date), (day))
|
Initial value:
DT_set_date((date),DT_year(date), \ (month), DT_day(date))
|
Initial value:
DT_set_date((date),(year),DT_month(date), \ DT_day(date))
|
DT_add_days.
Adds some number of days to the date.
date | The date to adjust. |
days |
The number of days to add.
|
|
DT_add_months.
Adds some number of months to the date.
date | The date to adjust. |
months |
The number of months to add.
|
|
DT_ascii.
Converts a date into ascii format suitable for displaying to the user. The format can be in one of several formats, which are DT_US_FORMAT, DT_EUROPE_FORMAT, or DT_UNIVERSAL_FORMAT. This symbol can be ORed with DT_NUMERIC_OUT if you want the output to be strictly numeric. The result will be stored in a statically declared buffer.
date | The date to convert |
format |
The desired output format, as described above
|
|
DT_ascii_r.
Converts a date into ascii format suitable for displaying to the user. The format can be in one of several formats, which are DT_US_FORMAT, DT_EUROPE_FORMAT, or DT_UNIVERSAL_FORMAT. This symbol can be ORed with DT_NUMERIC_OUT if you want the output to be strictly numeric. The result will be stored in a statically declared buffer.
buffer | The buffer where the output will be held |
buf_size | The size of the buffer |
date | The date to convert |
format |
The desired output format, as described above
|
|
DT_cal_day_to_col.
Given a date, return the column in which it would appear in the calendar.
date |
The date the convert
|
|
DT_cal_day_to_row.
Given a date, return the row in which it would appear in the calendar.
date |
The date the convert
|
|
DT_cal_row_col_to_day.
Given a month, row, and column, determine which day of the month should fill that location.
date | The DT_DATE structure containing the month and year. |
row | The row of the calendar (0-5) |
col |
The column of the calendar (0-6)
|
|
DT_cal_rows.
Determines how many rows would be in a rendered calendar for a given month.
date |
The DT_DATE structure holding the year and month to check
|
|
DT_copy_date.
Creates a new date structure by copying the elements from an existing one.
date |
The date to copy
|
|
DT_day.
Returns the day part of the date.
date |
The date to extract the day from
|
|
DT_days_between.
Determines how many days are between two dates. It subtracts the second from the first, so if the second date is more recent than the first, the result will be negative.
date1 | The first date |
date2 |
The second date
|
|
DT_days_this_month.
Given a date structure set to some month, return the number of days in the month.
date |
The date whose month we want to check.
|
|
DT_days_this_month_q.
Given a date structure set to some month, return the number of days in the month. This version is meant to make a quick calculation without the need to create a date structure.
year | The year for the month we're interested in |
month |
The month we're interested in (1-12)
|
|
DT_dow.
Returns the day of week for the time stored in a DT_DATE structure.
date |
The date structure to use
|
|
DT_dow_ascii.
Given a date, returns a pointer to an ascii version of the day of the week for that date.
date |
The date to convert
|
|
DT_easter.
Calculate easter for a given year. The date calculated will be for the year contained in the date.
date |
The DT_DATE structure
|
|
DT_event_adj_dow.
Given an event, this allows one to adjust to a particular day of the week. The adjustment can be made either in the forward or reverse direction, will never exceed one week, and is guaranteed to change the date. As an example, if you wanted the first Monday after April 15, and April 15 is on a Friday, this would cause the event to be pushed 3 days forward. If April 15 is on a Monday, the event will be pushed 7 days forward. If you want to disable this feature from an event, use DT_NONE for the event, and anything you want for the dow.
event | The event to adjust |
sign | DT_NEXT, DT_PREV, or DT_NONE |
dow: |
The day of the week DT_SUNDAY, DT_MONDAY, etc.
|
|
DT_event_adj_rel.
Give an event a relative adjustment. What this means is that after calculating the day an event occurs on, add this many days to it. That way, you can, for example, calculate election day as the first Tuesday after the first Monday of November every fourth year. Just calculate the first Monday in November, then add 1 to it. That's what this function is for. Notice, however, that the days you add or subtract must not be greater than the interval for the event.
event | The event to adjust |
adj |
The number of days to add to an event day
|
|
DT_event_multiday.
Sets an event to last more than a single day. Using this function, every day of an event will be considered part of the event. For more complex patterns, use the DT_event_pattern function instead.
event | The event to adjust |
len |
How long to make the event.
|
|
DT_event_next.
Given a date and an event, find the next occurance of the event. Notice that if an event occurs on the date supplied, that date will not be returned.
date | The date to check around |
event |
The event to locate
|
|
DT_event_pattern.
Sets a complex pattern for a multiday event. The input contains a string of 0's and 1's, with each character representing a single day. A 0 means the event does not take place on that day, while a 1 means it does.
event | The event to adjust |
pattern |
The pattern for the event
|
|
DT_find_dow_date.
Finds a date based on a day of week expression. For example, to find Thanksgiving, one would say the 4th Thursday in November. The year is taken from the current value in date. It is also possible, using DT_DAY for the day of week, to find the last day of the month (or the first, second, third, or fourth day of the month, but what's the use in that?)
date | The DT_DATE structure to modify |
ordinal | DT_FIRST, DT_SECOND, DT_THIRD, DT_FOURTH, or DT_LAST. |
dow | Day of week (0-6), or DT_DAY |
month |
The month (1-12)
|
|
DT_is_event_today.
Determine if an event occurs on a particular day. Given an event and a date, determines if the event occurs on that day.
date | The DT_DATE structure containing the day |
event |
The DT_EVENT structure containing the event
|
|
DT_mkdate.
Create a DT_DATE structure from a given year, month, and date
year | The full year (not just the last two digits) |
month | The month (1=Jan, 2=Feb, ... , 11=Nov, 12=Dec) |
date |
The day of the month
|
|
DT_mkdate_dow.
Sets the date according to a particular occurance of a day of the week in some month and year. This can be used to, for example, find the first Sunday in April of 2000, or the last day in October of 2000.
ordinal | DT_FIRST, DT_SECOND, DT_THIRD, DT_FOURTH, or DT_LAST. |
dow | Day of week (0-6), or DT_DAY |
month | The month (1-12) |
year |
The year
|
|
DT_mkdate_rata_die.
Given a date in rata die format, it returns a DT_DATE structure for it.
rata_die |
The date in rata die format
|
|
DT_mkevent.
Create a basic, no frills event. The event will recur at regular intervals, such as a weekly event (but not a monthly one - see DT_mkevent_monthly for that), and have bracketing dates between which the event will occur (so you can create an event that will only occur for one year, for example).
start | The date on which the event first occurs. |
end | The date after which the event will no longer occur. If you want the event to continue indefinitely, set this to NULL. |
interval |
How long between one event and the next (in days)?
|
|
DT_mkevent_monthly.
Create an event that will recur on a certain day of the month every "interval" months. You can create a yearly event by setting the interval to 12. The event will first occur on the start day, and occur no further than the end date, thus allowing one to bracket the dates in which the event will occur. Set the end date to NULL if you want to event to recur indefinetely.
start | The date on which the event first occurs. |
end | The date after which the event will no longer occur. If you want the event to continue indefinitely, set this to NULL. |
interval | How long between one event and the next (in months)? |
day |
The day of the month for the event.
|
|
DT_mkevent_monthly_dow.
Create an event that will recur on a particular day of the week at some point in a given month. This can be used for events which occur, for example, on the third Wednesday of every month (or every other month, or whatever). You need to pass a date for the first occurance of the event, and optionally a date for the last occurance. This last occurance can be NULL if the event to recur indefinitely. You must also specify how many months between events. If you want the event to occur every third month, set interval to 3. The ordinal and dow arguments work the same as the ones in DT_find_dow_date.
start | The date on which the event first occurs. |
end | The date after which the event will no longer occur. If you want the event to continue indefinitely, set this to NULL. |
interval | How long between one event and the next (in months)? |
ordinal | DT_FIRST, DT_SECOND, DT_THIRD, DT_FOURTH, or DT_LAST |
dow |
A day of the week, or DT_DAY
|
|
DT_month.
Returns the month part of the date.
date |
The date to extract the month from
|
|
DT_months_between.
Determines how many months are between two dates. It subtracts the second from the first, so if the second date is more recent than the first, the result will be negative. Also, this function completely ignores the day of the month, so consecutive days in different months, like Jan 31 and Feb 1 will have a difference of 1.
date1 | The first date |
date2 |
The second date
|
|
DT_moon_age.
Calculate the age of the moon in its synodic month. A synodic month Is the time the moon takes to go though all its phases, from one new moon to the next. Once we know the age, we can infer the phase of the moon from it.
date | A DT_DATE structure for the date to calculate for. |
timezone |
The timezone, represented as the number of hours relative to GMT
|
|
DT_rata_die.
Returns the date in rata die format
date |
The date to extract the year from
|
|
DT_rmdate.
Frees a DT_DATE structure. Call this when you are finished using one.
date |
The DT_DATE structure to free
|
|
DT_rmevent.
Frees the memory associated with an event. It can optionally free the memory associated with the two date structures inside as well.
event | The event to free. |
freeall |
Either DT_FREE_ALL or DT_FREE_NONE, referring to whether or not to free the internal date structures.
|
|
DT_set_date.
Sets the date in a date structure.
date | The DT_DATE structure |
year | The year |
month | The month |
day |
The day of the month
|
|
DT_set_rata_die.
Sets the date in a date structure using the rata die format.
date | The DT_DATE structure |
rata_die |
The date in rata die format
|
|
DT_year.
Returns the year part of the date.
date |
The date to extract the year from
|