|
GnuCash c935c2f+
|
Utility functions to handle date and time (adjusting, getting the current date, printing the date and time, etc.) More...
Files | |
| file | gnc-date.h |
| Date and Time handling routines. | |
Data Structures | |
| struct | Time64 |
Macros | |
| #define | MAX_DATE_LENGTH 34 |
| The maximum length of a string created by the date printers. | |
| #define | QOF_UTC_DATE_FORMAT "%Y-%m-%dT%H:%M:%SZ" |
| Constants. | |
| #define | DATE_FORMAT_FIRST QOF_DATE_FORMAT_US |
| #define | DATE_FORMAT_LAST QOF_DATE_FORMAT_UTC |
Typedefs | |
| typedef gint64 | time64 |
| Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux, support 64-bit time_t even on 32-bit architectures. | |
Enumerations | |
| enum | QofDateFormat { QOF_DATE_FORMAT_US , QOF_DATE_FORMAT_UK , QOF_DATE_FORMAT_CE , QOF_DATE_FORMAT_ISO , QOF_DATE_FORMAT_LOCALE , QOF_DATE_FORMAT_UTC , QOF_DATE_FORMAT_CUSTOM , QOF_DATE_FORMAT_UNSET } |
| Enum for determining a date format. More... | |
| enum | QofDateCompletion { QOF_DATE_COMPLETION_THISYEAR , QOF_DATE_COMPLETION_SLIDING } |
| Enum for date completion modes (for dates entered without year) More... | |
| enum | GNCDateMonthFormat { GNCDATE_MONTH_NUMBER , GNCDATE_MONTH_ABBREV , GNCDATE_MONTH_NAME } |
| This is how to format the month, as a number, an abbreviated string, or the full name. More... | |
Functions | |
| struct tm * | gnc_localtime (const time64 *secs) |
| fill out a time struct from a 64-bit time value. | |
| struct tm * | gnc_localtime_r (const time64 *secs, struct tm *time) |
| fill out a time struct from a 64-bit time value adjusted for the current time zone. | |
| struct tm * | gnc_gmtime (const time64 *secs) |
| fill out a time struct from a 64-bit time value | |
| gint | gnc_start_of_week (void) |
| returns an integer corresponding to locale start of week | |
| time64 | gnc_mktime (struct tm *time) |
| calculate seconds from the epoch given a time struct | |
| time64 | gnc_timegm (struct tm *time) |
| calculate seconds from the epoch given a time struct | |
| gchar * | gnc_ctime (const time64 *secs) |
| Return a string representation of a date from a 64-bit time value. | |
| time64 | gnc_time (time64 *tbuf) |
| get the current time | |
| gdouble | gnc_difftime (const time64 secs1, const time64 secs2) |
| Find the difference in seconds between two time values (deprecated) | |
| void | gnc_tm_free (struct tm *time) |
| free a struct tm* created with gnc_localtime() or gnc_gmtime() | |
| time64 | time64CanonicalDayTime (time64 t) |
| convert a time64 on a certain day (localtime) to the time64 representing midday on that day. | |
| time64 | gdate_to_time64 (GDate d) |
| Turns a GDate into a time64, returning the first second of the day. | |
| time64 | gnc_dmy2time64 (gint day, gint month, gint year) |
| Convert a day, month, and year to a time64, returning the first second of the day. | |
| time64 | gnc_dmy2time64_neutral (gint day, gint month, gint year) |
| Converts a day, month, and year to a time64 representing 11:00:00 UTC 11:00:00 UTC falls on the same time in almost all timezones, the exceptions being the +13, +14, and -12 timezones used by countries along the International Date Line. | |
| time64 | gnc_dmy2time64_end (gint day, gint month, gint year) |
| Same as gnc_dmy2time64, but last second of the day. | |
| time64 | gnc_iso8601_to_time64_gmt (const gchar *) |
| The gnc_iso8601_to_time64_gmt() routine converts an ISO-8601 style date/time string to time64. | |
| gchar * | gnc_time64_to_iso8601_buff (time64, char *buff) |
| The gnc_time64_to_iso8601_buff() routine takes the input UTC time64 value and prints it as an ISO-8601 style string. | |
Variables | |
| time64 | Time64::t |
| const char * | gnc_default_strftime_date_format |
| The default date format for use with strftime. | |
GValue | |
| GType | time64_get_type (void) |
| #define | GNC_TYPE_TIME64 (time64_get_type ()) |
String / DateFormat conversion. | |
| const gchar * | gnc_date_dateformat_to_string (QofDateFormat format) |
| The string->value versions return FALSE on success and TRUE on failure. | |
| gboolean | gnc_date_string_to_dateformat (const gchar *format_string, QofDateFormat *format) |
| Converts the date format to a printable string. | |
| const gchar * | gnc_date_monthformat_to_string (GNCDateMonthFormat format) |
| gboolean | gnc_date_string_to_monthformat (const gchar *format_string, GNCDateMonthFormat *format) |
| Converts the month format to a printable string. | |
| char * | gnc_print_time64 (time64 time, const char *format) |
| print a time64 as a date string per format | |
GDate time64 setters | |
| GDate * | gnc_g_date_new_today (void) |
| Returns a newly allocated date of the current clock time, taken from time(2). | |
| void | gnc_gdate_set_today (GDate *gd) |
| Set a GDate to the current day. | |
| void | gnc_gdate_set_time64 (GDate *gd, time64 time) |
| Set a GDate to a time64. | |
QofDateFormat functions | |
| QofDateFormat | qof_date_format_get (void) |
| The qof_date_format_get routine returns the date format that the date printing will use when printing a date, and the scanning routines will assume when parsing a date. | |
| void | qof_date_format_set (QofDateFormat df) |
| The qof_date_format_set() routine sets date format to one of US, UK, CE, OR ISO. | |
| const gchar * | qof_date_format_get_string (QofDateFormat df) |
| This function returns a strftime formatting string for printing an all numeric date (e.g. | |
| const gchar * | qof_date_text_format_get_string (QofDateFormat df) |
| This function returns a strftime formatting string for printing a date using words and numbers (e.g. | |
| void | qof_date_completion_set (QofDateCompletion dc, int backmonths) |
| The qof_date_completion_set() routing sets the date completion method to one of QOF_DATE_COMPLETION_THISYEAR (for completing the year to the current calendar year) or QOF_DATE_COMPLETION_SLIDING (for using a sliding 12-month window). | |
| gchar | dateSeparator (void) |
| dateSeparator Return the field separator for the current date format | |
Date Printing/Scanning functions | |
| gsize | qof_strftime (gchar *buf, gsize max, const gchar *format, const struct tm *tm) |
| qof_strftime calls qof_format_time to print a given time and afterwards tries to put the result into a buffer of fixed size. | |
| size_t | qof_print_date_dmy_buff (gchar *buff, size_t buflen, int day, int month, int year) |
| qof_print_date_dmy_buff Convert a date as day / month / year integers into a localized string representation | |
| size_t | qof_print_date_buff (char *buff, size_t buflen, time64 secs) |
| Convenience: calls through to qof_print_date_dmy_buff(). | |
| size_t | qof_print_gdate (char *buf, size_t bufflen, const GDate *gd) |
| Convenience; calls through to qof_print_date_dmy_buff(). | |
| char * | qof_print_date (time64 secs) |
| Convenience; calls through to qof_print_date_dmy_buff(). | |
| gchar * | gnc_date_interval_format (time64 from_date, time64 to_date) |
| size_t | qof_print_date_time_buff (char *buff, size_t len, time64 secs) |
| Returns the number of bytes printed. | |
| gboolean | qof_scan_date (const char *buff, int *day, int *month, int *year) |
| qof_scan_date Convert a string into day / month / year integers according to the current dateFormat value. | |
Date Start/End Adjustment routines | |
Given a time value, adjust it to be the beginning or end of that day. | |
| void | gnc_tm_set_day_neutral (struct tm *tm) |
| The gnc_tm_set_day_neutral() inline routine will set the appropriate fields in the struct tm to indicate 10:59am of that day. | |
| time64 | gnc_time64_get_day_start (time64 time_val) |
| The gnc_time64_get_day_start() routine will take the given time in seconds and adjust it to the first second of that day. | |
| time64 | gnc_time64_get_day_neutral (time64 time_val) |
| The gnc_time64_get_day_neutral() routine will take the given time in seconds and adjust it to 10:59:00Z of that day. | |
| time64 | gnc_time64_get_day_end (time64 time_val) |
| The gnc_time64_get_day_end() routine will take the given time in seconds and adjust it to the last second of that day. | |
| int | gnc_date_get_last_mday (int month, int year) |
| Get the numerical last date of the month. | |
Today's Date | |
| void | gnc_tm_get_today_start (struct tm *tm) |
| The gnc_tm_get_today_start() routine takes a pointer to a struct tm and fills it in with the first second of the today. | |
| void | gnc_tm_get_today_neutral (struct tm *tm) |
| The gnc_tm_get_today_start() routine takes a pointer to a struct tm and fills it in with the timezone neutral time (10:59:00Z). | |
| void | gnc_tm_get_today_end (struct tm *tm) |
| The gnc_tm_get_today_end() routine takes a pointer to a struct tm and fills it in with the last second of the today. | |
| time64 | gnc_time64_get_today_start (void) |
| The gnc_time64_get_today_start() routine returns a time64 value corresponding to the first second of today. | |
| time64 | gnc_time64_get_today_end (void) |
| The gnc_time64_get_today_end() routine returns a time64 value corresponding to the last second of today. | |
| char * | gnc_date_timestamp (void) |
| Make a timestamp in YYYYMMDDHHMMSS format. | |
| void | gnc_dow_abbrev (gchar *buf, int buf_len, int dow) |
| Localized DOW abbreviation. | |
| #define | MIN_BUF_LEN 10 |
GDate hash table support | |
| gint | gnc_gdate_equal (gconstpointer gda, gconstpointer gdb) |
| Compares two GDate*'s for equality; useful for using GDate*'s as GHashTable keys. | |
| guint | gnc_gdate_hash (gconstpointer gd) |
| Provides a "hash" of a GDate* value; useful for using GDate*'s as GHashTable keys. | |
GDate to time64 conversions | |
| GDate | time64_to_gdate (time64 t) |
| Returns the GDate in which the time64 occurs. | |
| time64 | gnc_time64_get_day_start_gdate (const GDate *date) |
| The gnc_time64_get_day_start() routine will take the given time in GLib GDate format and adjust it to the first second of that day. | |
| time64 | gnc_time64_get_day_end_gdate (const GDate *date) |
| The gnc_time64_get_day_end() routine will take the given time in GLib GDate format and adjust it to the last second of that day. | |
Date Manipulation | |
| void | gnc_gdate_set_month_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the month in which it falls. | |
| void | gnc_gdate_set_month_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the month in which it falls. | |
| void | gnc_gdate_set_prev_month_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the month prior to the one in which it falls. | |
| void | gnc_gdate_set_prev_month_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the month prior to the one in which it falls. | |
| void | gnc_gdate_set_quarter_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the quarter in which it falls. | |
| void | gnc_gdate_set_quarter_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the quarter in which it falls. | |
| void | gnc_gdate_set_prev_quarter_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the quarter prior to the one in which it falls. | |
| void | gnc_gdate_set_prev_quarter_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the quarter prior to the one in which it falls. | |
| void | gnc_gdate_set_year_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the year in which it falls. | |
| void | gnc_gdate_set_year_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the year in which it falls. | |
| void | gnc_gdate_set_prev_year_start (GDate *date) |
| This function modifies a GDate to set it to the first day of the year prior to the one in which it falls. | |
| void | gnc_gdate_set_prev_year_end (GDate *date) |
| This function modifies a GDate to set it to the last day of the year prior to the one in which it falls. | |
| void | gnc_gdate_set_fiscal_year_start (GDate *date, const GDate *year_end) |
| This function modifies a GDate to set it to the first day of the fiscal year in which it falls. | |
| void | gnc_gdate_set_fiscal_year_end (GDate *date, const GDate *year_end) |
| This function modifies a GDate to set it to the last day of the fiscal year in which it falls. | |
| void | gnc_gdate_set_prev_fiscal_year_start (GDate *date, const GDate *year_end) |
| This function modifies a GDate to set it to the first day of the fiscal year prior to the one in which it falls. | |
| void | gnc_gdate_set_prev_fiscal_year_end (GDate *date, const GDate *year_end) |
| This function modifies a GDate to set it to the last day of the fiscal year prior to the one in which it falls. | |
Utility functions to handle date and time (adjusting, getting the current date, printing the date and time, etc.)
Overall, this file is quite a mess.
An important note about time-keeping: The general goal of any program that works with numeric time values SHOULD BE to always stores and use UNIVERSAL TIME internally. Universal time is the 'one true time' that is independent of one's location on planet Earth. It is measured in seconds from midnight January 1, 1970 in localtime-Greenwich (GMT). If one wants to display the local time, then the display-print routine should make all final tweaks to print the local time. The local time must not be kept as a numeric value anywhere in the program. If one wants to parse a user's input string as if it were local time, then the output of the parse routine MUST BE universal time. A sane program must never ever store (to file or db) a time that is not Universal Time. Break these rules, and you will rue the day...
(to be renamed qofdate.h in libqof2.)
| #define DATE_FORMAT_FIRST QOF_DATE_FORMAT_US |
Definition at line 134 of file gnc-date.h.
| #define DATE_FORMAT_LAST QOF_DATE_FORMAT_UTC |
Definition at line 135 of file gnc-date.h.
| #define GNC_TYPE_TIME64 (time64_get_type ()) |
Definition at line 101 of file gnc-date.h.
| #define MAX_DATE_LENGTH 34 |
The maximum length of a string created by the date printers.
Definition at line 108 of file gnc-date.h.
| #define MIN_BUF_LEN 10 |
Definition at line 613 of file gnc-date.h.
| #define QOF_UTC_DATE_FORMAT "%Y-%m-%dT%H:%M:%SZ" |
Constants.
UTC date format string.
Time zone independent, date and time inclusive, as used in the QSF backend. The T and Z characters are from xsd:dateTime format in coordinated universal time, UTC. You can reproduce the string from the GNU/Linux command line using the date utility: date -u +Y-m-dTH:M:SZ = 2004-12-12T23:39:11Z The datestring must be time zone independent and include all specified fields. Remember to use gmtime() NOT localtime()!
Definition at line 119 of file gnc-date.h.
| typedef gint64 time64 |
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux, support 64-bit time_t even on 32-bit architectures.
See https://en.wikipedia.org/wiki/Year_2038_problem
For practical reasons – as not all have made the transition to 64-bit – we define our own 64-bit time type.
Definition at line 87 of file gnc-date.h.
| enum GNCDateMonthFormat |
This is how to format the month, as a number, an abbreviated string, or the full name.
Definition at line 148 of file gnc-date.h.
| enum QofDateCompletion |
Enum for date completion modes (for dates entered without year)
| Enumerator | |
|---|---|
| QOF_DATE_COMPLETION_THISYEAR | use current year |
| QOF_DATE_COMPLETION_SLIDING | use sliding 12-month window |
Definition at line 138 of file gnc-date.h.
| enum QofDateFormat |
Enum for determining a date format.
Definition at line 122 of file gnc-date.h.
| gchar dateSeparator | ( | void | ) |
dateSeparator Return the field separator for the current date format
Args: none
Return: date character
Globals: global dateFormat value
Definition at line 999 of file gnc-date.cpp.
| time64 gdate_to_time64 | ( | GDate | d | ) |
Turns a GDate into a time64, returning the first second of the day.
Definition at line 1323 of file gnc-date.cpp.
| gchar * gnc_ctime | ( | const time64 * | secs | ) |
Return a string representation of a date from a 64-bit time value.
| secs | Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment) |
Definition at line 256 of file gnc-date.cpp.
| const gchar * gnc_date_dateformat_to_string | ( | QofDateFormat | format | ) |
The string->value versions return FALSE on success and TRUE on failure.
Definition at line 281 of file gnc-date.cpp.
| int gnc_date_get_last_mday | ( | int | month, |
| int | year | ||
| ) |
Get the numerical last date of the month.
(28, 29, 30, 31)
Definition at line 413 of file gnc-date.cpp.
Definition at line 664 of file gnc-date.cpp.
| const gchar * gnc_date_monthformat_to_string | ( | GNCDateMonthFormat | format | ) |
Definition at line 335 of file gnc-date.cpp.
| gboolean gnc_date_string_to_dateformat | ( | const gchar * | format_string, |
| QofDateFormat * | format | ||
| ) |
Converts the date format to a printable string.
Note the reversed return values!
| gboolean gnc_date_string_to_monthformat | ( | const gchar * | format_string, |
| GNCDateMonthFormat * | format | ||
| ) |
Converts the month format to a printable string.
Note the reversed return values!
| char * gnc_date_timestamp | ( | void | ) |
Make a timestamp in YYYYMMDDHHMMSS format.
Definition at line 1174 of file gnc-date.cpp.
Find the difference in seconds between two time values (deprecated)
| secs1 | The first time value, in Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment) |
| secs2 | The second time value, in Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment) |
Definition at line 272 of file gnc-date.cpp.
| time64 gnc_dmy2time64_neutral | ( | gint | day, |
| gint | month, | ||
| gint | year | ||
| ) |
Converts a day, month, and year to a time64 representing 11:00:00 UTC 11:00:00 UTC falls on the same time in almost all timezones, the exceptions being the +13, +14, and -12 timezones used by countries along the International Date Line.
Since users in those timezones would see dates immediately change by one day, the function checks the current timezone for those changes and adjusts the UTC time so that the date will be consistent.
| void gnc_dow_abbrev | ( | gchar * | buf, |
| int | buf_len, | ||
| int | dow | ||
| ) |
Localized DOW abbreviation.
| buf_len | at least MIN_BUF_LEN |
| dow | struct tm semantics: 0=sunday .. 6=saturday |
Definition at line 1435 of file gnc-date.cpp.
| GDate * gnc_g_date_new_today | ( | void | ) |
Returns a newly allocated date of the current clock time, taken from time(2).
The caller must g_date_free() the object afterwards.
Definition at line 1298 of file gnc-date.cpp.
| gint gnc_gdate_equal | ( | gconstpointer | gda, |
| gconstpointer | gdb | ||
| ) |
Compares two GDate*'s for equality; useful for using GDate*'s as GHashTable keys.
Definition at line 1471 of file gnc-date.cpp.
| guint gnc_gdate_hash | ( | gconstpointer | gd | ) |
Provides a "hash" of a GDate* value; useful for using GDate*'s as GHashTable keys.
Definition at line 1477 of file gnc-date.cpp.
| void gnc_gdate_set_fiscal_year_end | ( | GDate * | date, |
| const GDate * | year_end | ||
| ) |
This function modifies a GDate to set it to the last day of the fiscal year in which it falls.
For example, if this function is called with a date of 2003-09-24 and a fiscal year ending July 31st, the date will be modified to 2004-07-31.
| date | The GDate to modify. |
| year_end | A GDate containing the last month and day of the fiscal year. The year field of this argument is ignored. |
Definition at line 1674 of file gnc-date.cpp.
| void gnc_gdate_set_fiscal_year_start | ( | GDate * | date, |
| const GDate * | year_end | ||
| ) |
This function modifies a GDate to set it to the first day of the fiscal year in which it falls.
For example, if this function is called with a date of 2003-09-24 and a fiscal year ending July 31st, the date will be modified to 2003-08-01.
| date | The GDate to modify. |
| year_end | A GDate containing the last month and day of the fiscal year. The year field of this argument is ignored. |
Definition at line 1650 of file gnc-date.cpp.
| void gnc_gdate_set_month_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the month in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-09-30.
| date | The GDate to modify. |
This function modifies a GDate to set it to the last day of the month in which it falls.
This routine has no knowledge of how many days are in a month, whether its a leap year, etc. All that information is contained in the glib date functions.
| date | The GDate to modify. |
Definition at line 1537 of file gnc-date.cpp.
| void gnc_gdate_set_month_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the month in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-09-01.
| date | The GDate to modify. |
Definition at line 1524 of file gnc-date.cpp.
| void gnc_gdate_set_prev_fiscal_year_end | ( | GDate * | date, |
| const GDate * | year_end | ||
| ) |
This function modifies a GDate to set it to the last day of the fiscal year prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 and a fiscal year ending July 31st, the date will be modified to 2003-07-31.
| date | The GDate to modify. |
| year_end | A GDate containing the last month and day of the fiscal year. The year field of this argument is ignored. |
Definition at line 1708 of file gnc-date.cpp.
| void gnc_gdate_set_prev_fiscal_year_start | ( | GDate * | date, |
| const GDate * | year_end | ||
| ) |
This function modifies a GDate to set it to the first day of the fiscal year prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 and a fiscal year ending July 31st, the date will be modified to 2002-08-01.
| date | The GDate to modify. |
| year_end | A GDate containing the last month and day of the fiscal year. The year field of this argument is ignored. |
Definition at line 1697 of file gnc-date.cpp.
| void gnc_gdate_set_prev_month_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the month prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-08-31.
| date | The GDate to modify. |
This function modifies a GDate to set it to the last day of the month prior to the one in which it falls.
This routine has no knowledge of how many days are in a month, whether its a leap year, etc. All that information is contained in the glib date functions.
| date | The GDate to modify. |
Definition at line 1569 of file gnc-date.cpp.
| void gnc_gdate_set_prev_month_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the month prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-08-01.
| date | The GDate to modify. |
This function modifies a GDate to set it to the first day of the month prior to the one in which it falls.
This routine has no knowledge of how many days are in a month, whether its a leap year, etc. All that information is contained in the glib date functions.
| date | The GDate to modify. |
Definition at line 1555 of file gnc-date.cpp.
| void gnc_gdate_set_prev_quarter_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the quarter prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-06-30.
| date | The GDate to modify. |
Definition at line 1611 of file gnc-date.cpp.
| void gnc_gdate_set_prev_quarter_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the quarter prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-04-01.
| date | The GDate to modify. |
Definition at line 1604 of file gnc-date.cpp.
| void gnc_gdate_set_prev_year_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the year prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2002-12-31.
| date | The GDate to modify. |
Definition at line 1641 of file gnc-date.cpp.
| void gnc_gdate_set_prev_year_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the year prior to the one in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2002-01-01.
| date | The GDate to modify. |
Definition at line 1634 of file gnc-date.cpp.
| void gnc_gdate_set_quarter_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the quarter in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-09-30.
| date | The GDate to modify. |
Definition at line 1592 of file gnc-date.cpp.
| void gnc_gdate_set_quarter_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the quarter in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-07-01.
| date | The GDate to modify. |
Definition at line 1579 of file gnc-date.cpp.
| void gnc_gdate_set_time64 | ( | GDate * | gd, |
| time64 | time | ||
| ) |
Set a GDate to a time64.
| gd | the date to act on |
| time | the time to set it to. |
Definition at line 1314 of file gnc-date.cpp.
| void gnc_gdate_set_today | ( | GDate * | gd | ) |
Set a GDate to the current day.
| gd | The date to act on |
Definition at line 1306 of file gnc-date.cpp.
| void gnc_gdate_set_year_end | ( | GDate * | date | ) |
This function modifies a GDate to set it to the last day of the year in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-12-31.
| date | The GDate to modify. |
Definition at line 1627 of file gnc-date.cpp.
| void gnc_gdate_set_year_start | ( | GDate * | date | ) |
This function modifies a GDate to set it to the first day of the year in which it falls.
For example, if this function is called with a date of 2003-09-24 the date will be modified to 2003-01-01.
| date | The GDate to modify. |
Definition at line 1620 of file gnc-date.cpp.
| struct tm * gnc_gmtime | ( | const time64 * | secs | ) |
fill out a time struct from a 64-bit time value
| secs | Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment) |
Definition at line 178 of file gnc-date.cpp.
| time64 gnc_iso8601_to_time64_gmt | ( | const gchar * | ) |
The gnc_iso8601_to_time64_gmt() routine converts an ISO-8601 style date/time string to time64.
Please note that ISO-8601 strings are a representation of Universal Time (UTC), and as such, they 'store' UTC. To make them human readable, they show time zone information along with a local-time string. But fundamentally, they are UTC. Thus, this routine takes a UTC input, and returns a UTC output.
For example: 1998-07-17 11:00:00.68-0500 is 680 milliseconds after 11 o'clock, central daylight time It is also 680 milliseconds after 16:00:00 hours UTC.
XXX Caution: this routine does not handle strings that specify times before January 1 1970.
| struct tm * gnc_localtime | ( | const time64 * | secs | ) |
fill out a time struct from a 64-bit time value.
| secs | Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment). |
Definition at line 103 of file gnc-date.cpp.
| struct tm * gnc_localtime_r | ( | const time64 * | secs, |
| struct tm * | time | ||
| ) |
fill out a time struct from a 64-bit time value adjusted for the current time zone.
| secs | Seconds since 00:00:00 UTC 01 January 1970 (negative values are seconds before that moment) |
| time | A struct tm* for the function to fill. The time is adjusted for the current local time zone. |
Definition at line 115 of file gnc-date.cpp.
| time64 gnc_mktime | ( | struct tm * | time | ) |
calculate seconds from the epoch given a time struct
| time | A struct tm* containing the date-time information. The time is understood to be in the current local time zone. |
Definition at line 219 of file gnc-date.cpp.
| char * gnc_print_time64 | ( | time64 | time, |
| const char * | format | ||
| ) |
print a time64 as a date string per format
| time | The time64 to print |
| format | A date format conforming to the strftime format rules. |
Definition at line 370 of file gnc-date.cpp.
| gint gnc_start_of_week | ( | void | ) |
returns an integer corresponding to locale start of week
Definition at line 195 of file gnc-date.cpp.
get the current time
| A | time64* which, if not NULL, will be filled in with the same value as is returned. |
Definition at line 262 of file gnc-date.cpp.
The gnc_time64_get_day_end() routine will take the given time in seconds and adjust it to the last second of that day.
Definition at line 1386 of file gnc-date.cpp.
| time64 gnc_time64_get_day_end_gdate | ( | const GDate * | date | ) |
The gnc_time64_get_day_end() routine will take the given time in GLib GDate format and adjust it to the last second of that day.
Definition at line 1502 of file gnc-date.cpp.
The gnc_time64_get_day_neutral() routine will take the given time in seconds and adjust it to 10:59:00Z of that day.
Definition at line 1377 of file gnc-date.cpp.
The gnc_time64_get_day_start() routine will take the given time in seconds and adjust it to the first second of that day.
Definition at line 1366 of file gnc-date.cpp.
| time64 gnc_time64_get_day_start_gdate | ( | const GDate * | date | ) |
The gnc_time64_get_day_start() routine will take the given time in GLib GDate format and adjust it to the first second of that day.
Definition at line 1488 of file gnc-date.cpp.
| time64 gnc_time64_get_today_end | ( | void | ) |
The gnc_time64_get_today_end() routine returns a time64 value corresponding to the last second of today.
Definition at line 1426 of file gnc-date.cpp.
| time64 gnc_time64_get_today_start | ( | void | ) |
The gnc_time64_get_today_start() routine returns a time64 value corresponding to the first second of today.
Definition at line 1417 of file gnc-date.cpp.
| gchar * gnc_time64_to_iso8601_buff | ( | time64 | time, |
| char * | buff | ||
| ) |
The gnc_time64_to_iso8601_buff() routine takes the input UTC time64 value and prints it as an ISO-8601 style string.
The buffer must be long enough to contain the NULL-terminated string (32 characters + NUL). This routine returns a pointer to the null terminator (and can thus be used in the 'stpcpy' metaphor of string concatenation).
Please note that ISO-8601 strings are a representation of Universal Time (UTC), and as such, they 'store' UTC. To make them human readable, they show time zone information along with a local-time string. But fundamentally, they are UTC. Thus, this routine takes a UTC input, and returns a UTC output.
The string generated by this routine uses the local time zone on the machine on which it is executing to create the time string.
Definition at line 1213 of file gnc-date.cpp.
| time64 gnc_timegm | ( | struct tm * | time | ) |
calculate seconds from the epoch given a time struct
| time | A struct tm* containing the date-time information The time is understood to be utc. |
Definition at line 235 of file gnc-date.cpp.
| void gnc_tm_free | ( | struct tm * | time | ) |
free a struct tm* created with gnc_localtime() or gnc_gmtime()
| time | The struct tm* to be freed. |
Definition at line 97 of file gnc-date.cpp.
| void gnc_tm_get_today_end | ( | struct tm * | tm | ) |
The gnc_tm_get_today_end() routine takes a pointer to a struct tm and fills it in with the last second of the today.
Definition at line 1411 of file gnc-date.cpp.
| void gnc_tm_get_today_neutral | ( | struct tm * | tm | ) |
The gnc_tm_get_today_start() routine takes a pointer to a struct tm and fills it in with the timezone neutral time (10:59:00Z).
Definition at line 1405 of file gnc-date.cpp.
| void gnc_tm_get_today_start | ( | struct tm * | tm | ) |
The gnc_tm_get_today_start() routine takes a pointer to a struct tm and fills it in with the first second of the today.
Definition at line 1399 of file gnc-date.cpp.
| void gnc_tm_set_day_neutral | ( | struct tm * | tm | ) |
The gnc_tm_set_day_neutral() inline routine will set the appropriate fields in the struct tm to indicate 10:59am of that day.
Definition at line 1340 of file gnc-date.cpp.
| void qof_date_completion_set | ( | QofDateCompletion | dc, |
| int | backmonths | ||
| ) |
The qof_date_completion_set() routing sets the date completion method to one of QOF_DATE_COMPLETION_THISYEAR (for completing the year to the current calendar year) or QOF_DATE_COMPLETION_SLIDING (for using a sliding 12-month window).
The sliding window starts 'backmonth' months before the current month (0-11)
Definition at line 468 of file gnc-date.cpp.
| QofDateFormat qof_date_format_get | ( | void | ) |
The qof_date_format_get routine returns the date format that the date printing will use when printing a date, and the scanning routines will assume when parsing a date.
Definition at line 428 of file gnc-date.cpp.
| const gchar * qof_date_format_get_string | ( | QofDateFormat | df | ) |
This function returns a strftime formatting string for printing an all numeric date (e.g.
2005-09-14). The string returned is based upon the location specified.
| df | The date style (us, uk, iso, etc) that should be provided. |
Definition at line 502 of file gnc-date.cpp.
| void qof_date_format_set | ( | QofDateFormat | df | ) |
The qof_date_format_set() routine sets date format to one of US, UK, CE, OR ISO.
Checks to make sure it's a legal value. Args: QofDateFormat: enumeration indicating preferred format
Definition at line 433 of file gnc-date.cpp.
| const gchar * qof_date_text_format_get_string | ( | QofDateFormat | df | ) |
This function returns a strftime formatting string for printing a date using words and numbers (e.g.
2005-September-14). The string returned is based upon the location specified.
| df | The date style (us, uk, iso, etc) that should be provided. |
Definition at line 525 of file gnc-date.cpp.
| char * qof_print_date | ( | time64 | secs | ) |
Convenience; calls through to qof_print_date_dmy_buff().
Return: string, which should be freed when no longer needed.
Definition at line 610 of file gnc-date.cpp.
| size_t qof_print_date_buff | ( | char * | buff, |
| size_t | buflen, | ||
| time64 | secs | ||
| ) |
Convenience: calls through to qof_print_date_dmy_buff().
Definition at line 574 of file gnc-date.cpp.
| size_t qof_print_date_dmy_buff | ( | gchar * | buff, |
| size_t | buflen, | ||
| int | day, | ||
| int | month, | ||
| int | year | ||
| ) |
qof_print_date_dmy_buff Convert a date as day / month / year integers into a localized string representation
Args: buff - pointer to previously allocated character array; its size must be at lease MAX_DATE_LENTH bytes. len - length of the buffer, in bytes. day - day of the month as 1 ... 31 month - month of the year as 1 ... 12 year - year (4-digit)
Returns: number of characters printed
Globals: global dateFormat value
| size_t qof_print_gdate | ( | char * | buf, |
| size_t | bufflen, | ||
| const GDate * | gd | ||
| ) |
Convenience; calls through to qof_print_date_dmy_buff().
Definition at line 598 of file gnc-date.cpp.
| gboolean qof_scan_date | ( | const char * | buff, |
| int * | day, | ||
| int * | month, | ||
| int * | year | ||
| ) |
qof_scan_date Convert a string into day / month / year integers according to the current dateFormat value.
Args: buff - pointer to date string day - will store day of the month as 1 ... 31 month - will store month of the year as 1 ... 12 year - will store the year (4-digit)
Return: TRUE if the string seemed to be a valid date; else FALSE.
Globals: uses global dateFormat value to assist in parsing.
Definition at line 991 of file gnc-date.cpp.
| gsize qof_strftime | ( | gchar * | buf, |
| gsize | max, | ||
| const gchar * | format, | ||
| const struct tm * | tm | ||
| ) |
qof_strftime calls qof_format_time to print a given time and afterwards tries to put the result into a buffer of fixed size.
| buf | A buffer. |
| max | The size of buf in bytes. |
| format | A format specification in UTF-8. |
| tm | A broken-down time. |
Definition at line 1129 of file gnc-date.cpp.
| GDate time64_to_gdate | ( | time64 | t | ) |
Returns the GDate in which the time64 occurs.
| t | The time64 |
Definition at line 1284 of file gnc-date.cpp.
convert a time64 on a certain day (localtime) to the time64 representing midday on that day.
Watch out - this is not the first second of the day, which is returned by various other functions returning a time64.
Definition at line 404 of file gnc-date.cpp.
|
extern |
The default date format for use with strftime.
Definition at line 74 of file gnc-date.cpp.
| time64 Time64::t |
Definition at line 93 of file gnc-date.h.