wibble 1.1
|
Functions that work with int[6] datetime values. More...
Functions | |
int | daysinmonth (int year, int month) |
Return the number of days in a month. | |
int | daysinyear (int year) |
Return the number of days in a year. | |
void | easter (int year, int *month, int *day) |
Compute the day of Easter. | |
void | lowerbound (const int *src, int *dst) |
Make a copy of the datetime, filling in missing values with the lowest possible value they can have. | |
void | lowerbound (int *val) |
Fill in the missing values of a datetime with the lowest possible value they can have. | |
void | normalise (int *res) |
Normalise a datetime, in place. | |
void | upperbound (const int *src, int *dst) |
Make a copy of the datetime, filling in missing values with the highest possible value they can have. | |
void | upperbound (int *val) |
Fill in the missing values of a datetime with the highest possible value they can have. | |
long long int | secondsfrom (int year, const int *val) |
Convert the given time in seconds elapsed since the beginning of the given year. | |
long long int | duration (const int *begin, const int *end) |
Give the duration in seconds of the interval between begin and end. | |
void | mergetime (const int *date, const int *time, int *dst) |
Make a copy of date, with the time part taken from time. | |
void | mergetime (int *date, const int *time) |
Replace the time part of date with the values from time. | |
void | totm (const int *src, struct tm *dst) |
Copy the values from an int[6] datetime into a struct tm. | |
void | fromtm (const struct tm &src, int *dst, int count=6) |
Copy the values from a struct tm to the first count values of the int[6] dst. | |
std::string | tostring (const int *val) |
Convert a datetime to a string. | |
void | today (int *dst) |
Fill in an int[6] with the UTC values for today (leaving the time of day elements to -1) | |
void | now (int *dst) |
Fill in an int[6] with the UTC values for now. | |
Functions that work with int[6] datetime values.
Return the number of days in a month.
Referenced by normalise(), and secondsfrom().
Return the number of days in a year.
Referenced by secondsfrom().
Give the duration in seconds of the interval between begin and end.
The result can be negative if end is an earlier date than begin.
References lowerbound(), secondsfrom(), and upperbound().
Compute the day of Easter.
The algorithm used is the Meeus/Jones/Butcher Gregorian algorithm described at http://en.wikipedia.org/wiki/Computus
Copy the values from a struct tm to the first count values of the int[6] dst.
Make a copy of the datetime, filling in missing values with the lowest possible value they can have.
Referenced by duration().
Fill in the missing values of a datetime with the lowest possible value they can have.
Make a copy of date, with the time part taken from time.
Replace the time part of date with the values from time.
Normalise a datetime, in place.
This function takes in input a datetime with no missing values, but some values can be arbitrarily out of range. The datetime will be normalised so that all the elements will be within range, and it will still represent the same instant.
For example (remember that months and days start from 1, so a day of 0 means "last day of previous month"):
\l normalise({2007, 0, 1, 0, 0, 0}) gives {2006, 12, 1, 0, 0, 0} \l normalise({2007, -11, 1, 0, 0, 0}) gives {2006, 1, 1, 0, 0, 0} \l normalise({2007, 1, -364, 0, 0, 0}) gives {2006, 1, 1, 0, 0, 0} \l normalise({2007, 1, 366, 0, 0, 0}) gives {2008, 1, 1, 0, 0, 0} \l normalise({2009, 1, -364, 0, 0, 0}) gives {2008, 1, 2, 0, 0, 0}, because 2008 is a leap year \l normalise({2008, 1, 1, 0, 0, -3600}) gives {2007, 12, 31, 23, 0, 0}
References daysinmonth().
Referenced by upperbound(), and upperbound().
Convert the given time in seconds elapsed since the beginning of the given year.
Compute the number of seconds that elapsed from the beginning of the given year until the given datetime.
It is assumed that year <= t[0]
It is assumed that year <= val[0]: giving a year greather than val[0] will give unpredictable results.
References daysinmonth(), and daysinyear().
Referenced by duration().
Fill in an int[6] with the UTC values for today (leaving the time of day elements to -1)
Copy the values from an int[6] datetime into a struct tm.
Make a copy of the datetime, filling in missing values with the highest possible value they can have.
References normalise().
Referenced by duration().
Fill in the missing values of a datetime with the highest possible value they can have.
References normalise().