Definition in file gnc-date.h.
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | timespec64 |
Use a 64-bit unsigned int timespec. More... | |
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. | |
Timespec functions | |
gboolean | timespec_equal (const Timespec *ta, const Timespec *tb) |
gint | timespec_cmp (const Timespec *ta, const Timespec *tb) |
Timespec | timespec_diff (const Timespec *ta, const Timespec *tb) |
Timespec | timespec_abs (const Timespec *t) |
Timespec | timespecCanonicalDayTime (Timespec t) |
void | timespecFromTime_t (Timespec *ts, time_t t) |
time_t | timespecToTime_t (Timespec ts) |
Timespec | gnc_dmy2timespec (gint day, gint month, gint year) |
Timespec | gnc_dmy2timespec_end (gint day, gint month, gint year) |
Timespec | gnc_iso8601_to_timespec_gmt (const gchar *) |
gchar * | gnc_timespec_to_iso8601_buff (Timespec ts, gchar *buff) |
void | gnc_timespec2dmy (Timespec ts, gint *day, gint *month, gint *year) |
gboolean | qof_date_add_days (Timespec *ts, gint days) |
Add a number of days to a Timespec and normalise. | |
gboolean | qof_date_add_months (Timespec *ts, gint months, gboolean track_last_day) |
Add a number of months to a Timespec and normalise. | |
void | date_add_months (struct tm *tm, gint months, gboolean track_last_day) |
time_t | xaccDMYToSec (gint day, gint month, gint year) |
glong | gnc_timezone (struct tm *tm) |
QofDateFormat functions | |
QofDateFormat | qof_date_format_get (void) |
void | qof_date_format_set (QofDateFormat df) |
const gchar * | qof_date_format_get_string (QofDateFormat df) |
const gchar * | qof_date_text_format_get_string (QofDateFormat df) |
Date Printing/Scanning functions | |
size_t | qof_print_date_dmy_buff (gchar *buff, size_t buflen, int day, int month, int year) |
size_t | qof_print_date_buff (char *buff, size_t buflen, time_t secs) |
size_t | qof_print_gdate (char *buf, size_t bufflen, GDate *gd) |
char * | qof_print_date (time_t secs) |
const char * | gnc_print_date (Timespec ts) |
size_t | qof_print_hours_elapsed_buff (char *buff, size_t len, int secs, gboolean show_secs) |
size_t | qof_print_minutes_elapsed_buff (char *buff, size_t len, int secs, gboolean show_secs) |
size_t | qof_print_time_buff (char *buff, size_t len, time_t secs) |
size_t | qof_print_date_time_buff (char *buff, size_t len, time_t secs) |
gboolean | qof_is_same_day (time_t, time_t) |
char * | xaccDateUtilGetStamp (time_t thyme) |
gboolean | qof_scan_date (const char *buff, int *day, int *month, int *year) |
gboolean | qof_scan_date_secs (const char *buff, time_t *secs) |
Date Start/End Adjustment routines | |
Given a time value, adjust it to be the beginning or end of that day. | |
static void | gnc_tm_set_day_start (struct tm *tm) |
static void | gnc_tm_set_day_middle (struct tm *tm) |
static void | gnc_tm_set_day_end (struct tm *tm) |
void | gnc_tm_get_day_start (struct tm *tm, time_t time_val) |
void | gnc_tm_get_day_end (struct tm *tm, time_t time_val) |
time_t | gnc_timet_get_day_start (time_t time_val) |
time_t | gnc_timet_get_day_end (time_t time_val) |
time_t | gnc_timet_get_day_start_gdate (GDate *date) |
time_t | gnc_timet_get_day_end_gdate (GDate *date) |
int | date_get_last_mday (struct tm *tm) |
gboolean | date_is_last_mday (struct tm *tm) |
int | gnc_date_my_last_mday (int month, int year) |
int | gnc_timespec_last_mday (Timespec ts) |
Today's Date | |
void | gnc_tm_get_today_start (struct tm *tm) |
void | gnc_tm_get_today_end (struct tm *tm) |
time_t | gnc_timet_get_today_start (void) |
time_t | gnc_timet_get_today_end (void) |
char * | xaccDateUtilGetStampNow (void) |
Defines | |
#define | MAX_DATE_LENGTH 31 |
#define | QOF_UTC_DATE_FORMAT "%Y-%m-%dT%H:%M:%SZ" |
UTC date format string. | |
#define | DATE_FORMAT_FIRST QOF_DATE_FORMAT_US |
#define | DATE_FORMAT_LAST QOF_DATE_FORMAT_LOCALE |
#define | qof_date_format_get_format qof_date_text_format_get_string |
Typedefs | |
typedef timespec64 | Timespec |
Enumerations | |
enum | QofDateFormat { QOF_DATE_FORMAT_US, QOF_DATE_FORMAT_UK, QOF_DATE_FORMAT_CE, QOF_DATE_FORMAT_ISO, QOF_DATE_FORMAT_UTC, QOF_DATE_FORMAT_LOCALE, QOF_DATE_FORMAT_CUSTOM } |
enum | GNCDateMonthFormat { GNCDATE_MONTH_NUMBER, GNCDATE_MONTH_ABBREV, GNCDATE_MONTH_NAME } |
Functions | |
gchar | dateSeparator (void) |
|
The Timespec is just like the unix 'struct timespec' except that we use a 64-bit unsigned int to store the seconds. This should adequately cover dates in the distant future as well as the distant past, as long as they're not more than a couple dozen times the age of the universe Values of this type can range from 0 to 18,446,744,073,709,551,615. Definition at line 169 of file gnc-date.h. |
|
|
|
Get the numerical last date of the month. (28, 29, 30, 31) Definition at line 285 of file gnc-date.c.
|
|
Is the mday field the last day of the specified month. Definition at line 297 of file gnc-date.c.
|
|
dateSeparator Return the field separator for the current date format Args: none Return: date character Globals: global dateFormat value Definition at line 922 of file gnc-date.c. 00923 { 00924 static char locale_separator = '\0'; 00925 00926 switch (dateFormat) 00927 { 00928 case QOF_DATE_FORMAT_CE: 00929 return '.'; 00930 case QOF_DATE_FORMAT_ISO: 00931 case QOF_DATE_FORMAT_UTC: 00932 return '-'; 00933 case QOF_DATE_FORMAT_US: 00934 case QOF_DATE_FORMAT_UK: 00935 default: 00936 return '/'; 00937 case QOF_DATE_FORMAT_LOCALE: 00938 if (locale_separator != '\0') 00939 return locale_separator; 00940 else 00941 { /* Make a guess */ 00942 unsigned char string[256]; 00943 struct tm *tm; 00944 time_t secs; 00945 unsigned char *s; 00946 00947 secs = time(NULL); 00948 tm = localtime(&secs); 00949 strftime(string, sizeof(string), GNC_D_FMT, tm); 00950 00951 for (s = string; s != '\0'; s++) 00952 if (!isdigit(*s)) 00953 return (locale_separator = *s); 00954 } 00955 } 00956 00957 return '\0'; 00958 }
|
|
Definition at line 263 of file gnc-date.c. 00264 { 00265 static int last_day_of_month[2][12] = { 00266 /* non leap */ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, 00267 /* leap */ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} 00268 }; 00269 00270 /* Is this a leap year? */ 00271 if (year % 2000 == 0) return last_day_of_month[1][month-1]; 00272 if (year % 400 == 0 ) return last_day_of_month[0][month-1]; 00273 if (year % 4 == 0 ) return last_day_of_month[1][month-1]; 00274 return last_day_of_month[0][month-1]; 00275 }
|
|
Converts the date format to a printable string. Note the reversed return values!
|
|
Converts the month format to a printable string. Note the reversed return values!
|
|
Convert a day, month, and year to a Timespec |
|
Same as gnc_dmy2timespec, but last second of the day |
|
The gnc_iso8601_to_timespec_gmt() routine converts an ISO-8601 style date/time string to Timespec. 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 timezone information along with a local-time string. But fundamentally, they *are* UTC. Thus, thir 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 millisecs after 16:00:00 hours UTC.
|
|
Convenience; calls through to qof_print_date_dmy_buff(). Return: static global string.
Definition at line 530 of file gnc-date.c. 00531 { 00532 static char buff[MAX_DATE_LENGTH]; 00533 time_t t; 00534 00535 t = ts.tv_sec + (ts.tv_nsec / 1000000000.0); 00536 00537 qof_print_date_buff (buff, MAX_DATE_LENGTH, t); 00538 00539 return buff; 00540 }
|
|
DOCUMENT ME! FIXME: Probably similar to xaccDMYToSec() this date routine might return incorrect values for dates before 1970. |
|
DOCUMENT ME! Probably the same as date_get_last_mday() Definition at line 1193 of file gnc-date.c. 01194 { 01195 struct tm *result; 01196 time_t t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND); 01197 result = localtime(&t_secs); 01198 return date_get_last_mday (result); 01199 }
|
|
The gnc_timespec_to_iso8601_buff() routine takes the input UTC Timespec 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 timezone 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 timezone on the machine on which it is executing to create the timestring. |
|
The gnc_timet_get_day_end() routine will take the given time in seconds and adjust it to the last second of that day. Definition at line 1350 of file gnc-date.c. 01351 { 01352 struct tm tm; 01353 01354 gnc_tm_get_day_end(&tm, time_val); 01355 return mktime(&tm); 01356 }
|
|
The gnc_timet_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 1377 of file gnc-date.c. 01378 { 01379 struct tm stm; 01380 time_t secs; 01381 01382 stm.tm_year = g_date_get_year (date) - 1900; 01383 stm.tm_mon = g_date_get_month (date) - 1; 01384 stm.tm_mday = g_date_get_day (date); 01385 gnc_tm_set_day_end(&stm); 01386 01387 /* Compute number of seconds */ 01388 secs = mktime (&stm); 01389 return secs; 01390 }
|
|
The gnc_timet_get_day_start() routine will take the given time in seconds and adjust it to the last second of that day. Definition at line 1341 of file gnc-date.c. 01342 { 01343 struct tm tm; 01344 01345 gnc_tm_get_day_start(&tm, time_val); 01346 return mktime(&tm); 01347 }
|
|
The gnc_timet_get_day_start() routine will take the given time in GLib GDate format and adjust it to the last second of that day.
Definition at line 1361 of file gnc-date.c. 01362 { 01363 struct tm stm; 01364 time_t secs; 01365 01366 stm.tm_year = g_date_get_year (date) - 1900; 01367 stm.tm_mon = g_date_get_month (date) - 1; 01368 stm.tm_mday = g_date_get_day (date); 01369 gnc_tm_set_day_start(&stm); 01370 01371 /* Compute number of seconds */ 01372 secs = mktime (&stm); 01373 return secs; 01374 }
|
|
The gnc_timet_get_today_end() routine returns a time_t value corresponding to the last second of today. Definition at line 1417 of file gnc-date.c. 01418 { 01419 struct tm tm; 01420 01421 gnc_tm_get_day_end(&tm, time(NULL)); 01422 return mktime(&tm); 01423 }
|
|
The gnc_timet_get_today_start() routine returns a time_t value corresponding to the first second of today. Definition at line 1408 of file gnc-date.c. 01409 { 01410 struct tm tm; 01411 01412 gnc_tm_get_day_start(&tm, time(NULL)); 01413 return mktime(&tm); 01414 }
|
|
The gnc_timezone function returns the number of seconds *west* of UTC represented by the tm argument, adjusted for daylight savings time. This function requires a tm argument returned by localtime or set by mktime. This is a strange function! It requires that localtime or mktime be called before use. Subsequent calls to localtime or mktime *may* invalidate the result! The actual contents of tm *may* be used for both timezone offset and daylight savings time, or only daylight savings time! Timezone stuff under unix is not standardized and is a big mess. Definition at line 1294 of file gnc-date.c. 01295 { 01296 g_return_val_if_fail (tm != NULL, 0); 01297 01298 #ifdef HAVE_STRUCT_TM_GMTOFF 01299 /* tm_gmtoff is seconds *east* of UTC and is 01300 * already adjusted for daylight savings time. */ 01301 return -(tm->tm_gmtoff); 01302 #else 01303 /* timezone is seconds *west* of UTC and is 01304 * not adjusted for daylight savings time. 01305 * In Spring, we spring forward, wheee! */ 01306 return (long int)(timezone - (tm->tm_isdst > 0 ? 3600 : 0)); 01307 #endif 01308 }
|
|
The gnc_tm_get_day_end() routine will convert the given time in seconds to the struct tm format, and then adjust it to the last second of that day. Definition at line 1333 of file gnc-date.c. 01334 { 01335 /* Get the equivalent time structure */ 01336 tm = localtime_r(&time_val, tm); 01337 gnc_tm_set_day_end(tm); 01338 }
|
|
The gnc_tm_get_day_start() routine will convert the given time in seconds to the struct tm format, and then adjust it to the first second of that day. Definition at line 1325 of file gnc-date.c. 01326 { 01327 /* Get the equivalent time structure */ 01328 tm = localtime_r(&time_val, tm); 01329 gnc_tm_set_day_start(tm); 01330 }
|
|
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 1402 of file gnc-date.c.
|
|
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 1396 of file gnc-date.c.
|
|
The gnc_tm_set_day_start() inline routine will set the appropriate fields in the struct tm to indicate the last second of that day. This routine assumes that the contents of the data structure is already in normalized form. Definition at line 479 of file gnc-date.h. 00480 { 00481 /* Last second of the day */ 00482 tm->tm_hour = 23; 00483 tm->tm_min = 59; 00484 tm->tm_sec = 59; 00485 tm->tm_isdst = -1; 00486 }
|
|
The gnc_tm_set_day_start() inline routine will set the appropriate fields in the struct tm to indicate noon of that day. This routine assumes that the contents of the data structure is already in normalized form. Definition at line 465 of file gnc-date.h. 00466 { 00467 /* First second of the day */ 00468 tm->tm_hour = 12; 00469 tm->tm_min = 0; 00470 tm->tm_sec = 0; 00471 tm->tm_isdst = -1; 00472 }
|
|
The gnc_tm_set_day_start() inline routine will set the appropriate fields in the struct tm to indicate the first second of that day. This routine assumes that the contents of the data structure is already in normalized form. Definition at line 451 of file gnc-date.h. 00452 { 00453 /* First second of the day */ 00454 tm->tm_hour = 0; 00455 tm->tm_min = 0; 00456 tm->tm_sec = 0; 00457 tm->tm_isdst = -1; 00458 }
|
|
Add a number of days to a Timespec and normalise. Together with qof_date_add_months, replaces date_add_months.
Definition at line 1426 of file gnc-date.c. 01427 { 01428 struct tm tm; 01429 time_t tt; 01430 01431 g_return_val_if_fail(ts, FALSE); 01432 tt = timespecToTime_t(*ts); 01433 #ifdef HAVE_GMTIME_R 01434 tm = *gmtime_r(&tt, &tm); 01435 #else 01436 tm = *gmtime(&tt); 01437 #endif 01438 tm.tm_mday += days; 01439 /* let mktime normalise the months and year 01440 because we aren't tracking last_day_of_month */ 01441 tt = mktime(&tm); 01442 if(tt < 0) { return FALSE; } 01443 timespecFromTime_t(ts, tt); 01444 return TRUE; 01445 }
|
|
Add a number of months to a Timespec and normalise. Optionally track the last day of the month so that adding one month to 31st January returns 28th February (29th in a leap year) and adding three months returns 30th April.
Definition at line 1448 of file gnc-date.c. 01449 { 01450 struct tm tm; 01451 time_t tt; 01452 gint new_last_mday; 01453 gboolean was_last_day; 01454 01455 g_return_val_if_fail(ts, FALSE); 01456 tt = timespecToTime_t(*ts); 01457 #ifdef HAVE_GMTIME_R 01458 tm = *gmtime_r(&tt, &tm); 01459 #else 01460 tm = *gmtime(&tt); 01461 #endif 01462 was_last_day = date_is_last_mday(&tm); 01463 tm.tm_mon += months; 01464 while (tm.tm_mon > 11) { 01465 tm.tm_mon -= 12; 01466 tm.tm_year++; 01467 } 01468 if (track_last_day) { 01469 /* Track last day of the month, i.e. 1/31 -> 2/28 -> 3/31 */ 01470 new_last_mday = date_get_last_mday(&tm); 01471 if (was_last_day || (tm.tm_mday > new_last_mday)) { 01472 tm.tm_mday = new_last_mday; 01473 } 01474 } 01475 tt = mktime(&tm); 01476 if(tt < 0) { return FALSE; } 01477 timespecFromTime_t(ts, tt); 01478 return TRUE; 01479 }
|
|
The qof_date_format_get routine returns the date format that the date printing will use when printing a date, and the scaning routines will assume when parsing a date.
Definition at line 343 of file gnc-date.c.
|
|
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.
Definition at line 383 of file gnc-date.c. 00384 { 00385 switch(df) { 00386 case QOF_DATE_FORMAT_US: 00387 return "%m/%d/%y"; 00388 case QOF_DATE_FORMAT_UK: 00389 return "%d/%m/%y"; 00390 case QOF_DATE_FORMAT_CE: 00391 return "%d.%m.%y"; 00392 case QOF_DATE_FORMAT_UTC: 00393 return "%Y-%m-%dT%H:%M:%SZ"; 00394 case QOF_DATE_FORMAT_ISO: 00395 return "%y-%m-%d"; 00396 case QOF_DATE_FORMAT_LOCALE: 00397 default: 00398 return GNC_D_FMT; 00399 }; 00400 }
|
|
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 359 of file gnc-date.c. 00360 { 00361 if(df >= DATE_FORMAT_FIRST && df <= DATE_FORMAT_LAST) 00362 { 00363 prevQofDateFormat = dateFormat; 00364 dateFormat = df; 00365 } 00366 else 00367 { /* hack alert - Use a neutral default. */ 00368 PERR("non-existent date format set attempted. Setting ISO default"); 00369 prevQofDateFormat = dateFormat; 00370 dateFormat = QOF_DATE_FORMAT_ISO; 00371 } 00372 00373 return; 00374 }
|
|
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.
Definition at line 411 of file gnc-date.c. 00412 { 00413 switch(df) { 00414 case QOF_DATE_FORMAT_US: 00415 return "%b %d, %y"; 00416 case QOF_DATE_FORMAT_UK: 00417 case QOF_DATE_FORMAT_CE: 00418 return "%d %b, %y"; 00419 case QOF_DATE_FORMAT_UTC: 00420 return "%Y-%m-%dT%H:%M:%SZ"; 00421 case QOF_DATE_FORMAT_ISO: 00422 return "%y-%b-%d"; 00423 case QOF_DATE_FORMAT_LOCALE: 00424 default: 00425 return GNC_D_FMT; 00426 }; 00427 }
|
|
The qof_is_same_day() routine returns 0 if both times are in the same day. Definition at line 697 of file gnc-date.c. 00698 { 00699 struct tm lta, ltb; 00700 lta = *localtime (&ta); 00701 ltb = *localtime (&tb); 00702 if (lta.tm_year == ltb.tm_year) 00703 { 00704 return (ltb.tm_yday - lta.tm_yday); 00705 } 00706 return (ltb.tm_year - lta.tm_year)*365; /* very approximate */ 00707 }
|
|
Convenience; calls through to qof_print_date_dmy_buff(). Return: string, which should be freed when no longer needed. Definition at line 522 of file gnc-date.c. 00523 { 00524 char buff[MAX_DATE_LENGTH]; 00525 qof_print_date_buff (buff, MAX_DATE_LENGTH, t); 00526 return g_strdup (buff); 00527 }
|
|
Convenience: calls through to qof_print_date_dmy_buff(). Definition at line 498 of file gnc-date.c. 00499 { 00500 struct tm *theTime; 00501 00502 if (!buff) return 0 ; 00503 00504 theTime = localtime (&t); 00505 00506 return qof_print_date_dmy_buff (buff, len, 00507 theTime->tm_mday, 00508 theTime->tm_mon + 1, 00509 theTime->tm_year + 1900); 00510 }
|
|
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 |
|
Convenience; calls through to qof_print_date_dmy_buff(). Definition at line 513 of file gnc-date.c. 00514 { 00515 return qof_print_date_dmy_buff( buf, len, 00516 g_date_get_day(gd), 00517 g_date_get_month(gd), 00518 g_date_get_year(gd) ); 00519 }
|
|
The qof_print_hours_elapsed_buff() routine will print the 'secs' argument as HH:MM, and will print the seconds if show_secs is true. Thus, for example, secs=3599 will print as 0:59 Returns the number of bytes copied. Definition at line 545 of file gnc-date.c. 00546 { 00547 size_t flen; 00548 if (0 <= secs) 00549 { 00550 if (show_secs) 00551 { 00552 flen = g_snprintf(buff, len, 00553 "%02d:%02d:%02d", (int)(secs / 3600), 00554 (int)((secs % 3600) / 60), (int)(secs % 60)); 00555 } 00556 else 00557 { 00558 flen = g_snprintf(buff, len, 00559 "%02d:%02d", (int)(secs / 3600), 00560 (int)((secs % 3600) / 60)); 00561 } 00562 } 00563 else 00564 { 00565 if (show_secs) 00566 { 00567 flen = g_snprintf(buff, len, 00568 "-%02d:%02d:%02d", (int)(-secs / 3600), 00569 (int)((-secs % 3600) / 60), (int)(-secs % 60)); 00570 } 00571 else 00572 { 00573 flen = g_snprintf(buff, len, 00574 "-%02d:%02d", (int)(-secs / 3600), 00575 (int)((-secs % 3600) / 60)); 00576 } 00577 } 00578 return flen; 00579 }
|
|
The qof_print_time_buff() routine prints only the hour-part of the date. Thus, if secs is ... Returns the number of bytes printed. Definition at line 676 of file gnc-date.c. 00677 { 00678 int flen; 00679 struct tm ltm, gtm; 00680 00681 if (!buff) return 0; 00682 if(dateFormat == QOF_DATE_FORMAT_UTC) 00683 { 00684 gtm = *gmtime (&secs); 00685 flen = strftime(buff, len, QOF_UTC_DATE_FORMAT, >m); 00686 return flen; 00687 } 00688 ltm = *localtime (&secs); 00689 flen = strftime (buff, len, GNC_T_FMT, <m); 00690 00691 return flen; 00692 }
|
|
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 902 of file gnc-date.c.
|
|
as above, but returns seconds Definition at line 908 of file gnc-date.c. 00909 { 00910 gboolean rc; 00911 int day, month, year; 00912 00913 rc = qof_scan_date_internal(buff, &day, &month, &year, dateFormat); 00914 if (secs) *secs = xaccDMYToSec (day, month, year); 00915 00916 return rc; 00917 }
|
|
absolute value, also normalised Definition at line 230 of file gnc-date.c. 00231 { 00232 Timespec retval = *t; 00233 00234 timespec_normalize(&retval); 00235 if (retval.tv_sec < 0) 00236 { 00237 retval.tv_sec = - retval.tv_sec; 00238 retval.tv_nsec = - retval.tv_nsec; 00239 } 00240 00241 return retval; 00242 }
|
|
comparison: if (ta < tb) -1; else if (ta > tb) 1; else 0; Definition at line 209 of file gnc-date.c. 00210 { 00211 if(ta == tb) return 0; 00212 if(ta->tv_sec < tb->tv_sec) return -1; 00213 if(ta->tv_sec > tb->tv_sec) return 1; 00214 if(ta->tv_nsec < tb->tv_nsec) return -1; 00215 if(ta->tv_nsec > tb->tv_nsec) return 1; 00216 return 0; 00217 }
|
|
difference between ta and tb, results are normalised ie tv_sec and tv_nsec of the result have the same size abs(result.tv_nsec) <= 1000000000 Definition at line 220 of file gnc-date.c. 00221 { 00222 Timespec retval; 00223 retval.tv_sec = ta->tv_sec - tb->tv_sec; 00224 retval.tv_nsec = ta->tv_nsec - tb->tv_nsec; 00225 timespec_normalize(&retval); 00226 return retval; 00227 }
|
|
strict equality Definition at line 200 of file gnc-date.c. 00201 { 00202 if(ta == tb) return TRUE; 00203 if(ta->tv_sec != tb->tv_sec) return FALSE; 00204 if(ta->tv_nsec != tb->tv_nsec) return FALSE; 00205 return TRUE; 00206 }
|
|
convert a timepair on a certain day (localtime) to the timepair representing midday on that day Definition at line 250 of file gnc-date.c. 00251 { 00252 struct tm tm, *result; 00253 Timespec retval; 00254 time_t t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND); 00255 result = localtime(&t_secs); 00256 tm = *result; 00257 gnc_tm_set_day_middle(&tm); 00258 retval.tv_sec = mktime(&tm); 00259 retval.tv_nsec = 0; 00260 return retval; 00261 }
|
|
Turns a time_t into a Timespec Definition at line 1312 of file gnc-date.c.
|
|
Turns a Timespec into a time_t Definition at line 1319 of file gnc-date.c. 01320 { 01321 return ts.tv_sec; 01322 }
|
|
The xaccDateUtilGetStamp() routine will take the given time in seconds and return a buffer containing a textual for the date.
Definition at line 973 of file gnc-date.c. 00974 { 00975 struct tm *stm; 00976 00977 stm = localtime (&thyme); 00978 00979 return g_strdup_printf("%04d%02d%02d%02d%02d%02d", 00980 (stm->tm_year + 1900), 00981 (stm->tm_mon +1), 00982 stm->tm_mday, 00983 stm->tm_hour, 00984 stm->tm_min, 00985 stm->tm_sec 00986 ); 00987 }
|
|
The xaccDateUtilGetStampNow() routine returns the current time in seconds in textual format.
Definition at line 1000 of file gnc-date.c.
|
|
|