Full range replacement for struct tm.
Based on struct tm but using signed integers. The year value uses a signed 64bit value to prevent overflows. (A glong is insufficient by two orders of magnitude.) To retain precision, a QofDate includes a nanoseconds value that can be used with a QofTime and a 64bit value for seconds.
- Note
- All QofDate values can be negative. The normalising cascade handles rollovers. e.g. If a QofDate qd_min value is 5 initially, setting qd_sec to 68 causes qd_sec to actually hold the value 8 and qd_min to hold the value 6. Alternatively, setting qd_sec to -64 with qd_min set to 5 causes qd_sec to hold the value 56 and qd_min to hold the value 3.
- Todo:
- check - years work like this, days don't!! Only qd_year retains a negative value once set. Adding one year to a negative QofDate causes the QofDate to be set to one year further into the past. This follows the same pattern as typical BC dates: the 1st of May 501BC is further into the past than the 5th of May 500BC.
Why is this a date? Because it represents a date, broken down into the component variables. A QofTime always (and only) relates to seconds, a QofDate always relates to how that number of seconds can be represented as a sequence of days, months, years etc.
- Note
- Although values can be set directly, qof_date_valid should be called before attempting to manipulate a QofDate.
- Todo:
- Reorganise the qof_time_* functions to reflect this statement. qof_time_set_day_end should be qof_date_set_day_end and the various qof_date_time functions need to be reviewed.
Definition at line 138 of file qofdate.h.
gboolean QofDate_s::qd_valid |
If the QofDate is valid or merely initialised.
Some QofDate values are invalid when initialised to zero (e.g. qm_mday). Avoid setting this value manually (just because it can be done, does not mean doing it is a good idea). Use qof_date_valid to ensure that values like qd_wday, qd_yday, qd_gmt_off and qd_is_dst are set correctly.
Definition at line 217 of file qofdate.h.