GnuCash  2.6.18
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Date: Date and Time Printing, Parsing and Manipulation

Files

file  gnc-date.h
 Date and Time handling routines.
 

Data Structures

struct  Timespec
 Use a 64-bit unsigned int timespec. More...
 

Macros

#define MAX_DATE_LENGTH   34
 
#define MAXTIME   INT64_C(253402300799)
 
#define MINTIME   INT64_C(-62135596800)
 
#define QOF_UTC_DATE_FORMAT   "%Y-%m-%dT%H:%M:%SZ"
 UTC date format string. More...
 
#define DATE_FORMAT_FIRST   QOF_DATE_FORMAT_US
 
#define DATE_FORMAT_LAST   QOF_DATE_FORMAT_UTC
 
#define qof_date_format_get_format   qof_date_text_format_get_string
 

Typedefs

typedef gint64 time64
 

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  QofDateCompletion { QOF_DATE_COMPLETION_THISYEAR, QOF_DATE_COMPLETION_SLIDING }
 
enum  GNCDateMonthFormat { GNCDATE_MONTH_NUMBER, GNCDATE_MONTH_ABBREV, GNCDATE_MONTH_NAME }
 

Functions

struct tm * gnc_localtime (const time64 *secs)
 fill out a time struct from a 64-bit time value. More...
 
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. More...
 
struct tm * gnc_gmtime (const time64 *secs)
 fill out a time struct from a 64-bit time value More...
 
time64 gnc_mktime (struct tm *time)
 calculate seconds from the epoch given a time struct More...
 
time64 gnc_timegm (struct tm *time)
 calculate seconds from the epoch given a time struct More...
 
gchar * gnc_ctime (const time64 *secs)
 Return a string representation of a date from a 64-bit time value. More...
 
time64 gnc_time (time64 *tbuf)
 get the current local time More...
 
time64 gnc_time_utc (time64 *tbuf)
 get the current UTC time More...
 
gdouble gnc_difftime (const time64 secs1, const time64 secs2)
 Find the difference in seconds between two time values. More...
 
GDateTime * gnc_g_date_time_new_from_unix_local (time64 time)
 
void gnc_tm_free (struct tm *time)
 free a struct tm* created with gnc_localtime() or gnc_gmtime() More...
 
GDateTime * gnc_g_date_time_new_from_timespec_local (Timespec tm)
 Create a GDateTime from a Timespec. More...
 
void qof_date_completion_set (QofDateCompletion dc, int backmonths)
 
gchar dateSeparator (void)
 

Variables

const char * gnc_default_strftime_date_format
 

GValue

GType timespec_get_type (void)
 
#define GNC_TYPE_TIMESPEC   (timespec_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. More...
 
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. More...
 

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)
 
Timespec timespec_now (void)
 
void timespecFromTime64 (Timespec *ts, time64 t)
 
time64 timespecToTime64 (Timespec ts)
 
GDate * gnc_g_date_new_today (void)
 
GDate timespec_to_gdate (Timespec ts)
 
Timespec gdate_to_timespec (GDate d)
 
Timespec gnc_dmy2timespec (gint day, gint month, gint year)
 
Timespec gnc_dmy2timespec_end (gint day, gint month, gint year)
 
Timespec gnc_dmy2timespec_neutral (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)
 
glong gnc_timezone (const 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

gsize qof_strftime (gchar *buf, gsize max, const gchar *format, const struct tm *tm)
 
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, time64 secs)
 
size_t qof_print_gdate (char *buf, size_t bufflen, const GDate *gd)
 
char * qof_print_date (time64 secs)
 
const char * gnc_print_date (Timespec ts)
 
size_t qof_print_date_time_buff (char *buff, size_t len, time64 secs)
 
gboolean qof_scan_date (const char *buff, int *day, int *month, int *year)
 

Date Start/End Adjustment routines

Given a time value, adjust it to be the beginning or end of that day.

time64 gnc_time64_get_day_start (time64 time_val)
 
time64 gnc_time64_get_day_end (time64 time_val)
 
int gnc_date_get_last_mday (int month, int year)
 

Today's Date

void gnc_tm_get_today_start (struct tm *tm)
 
void gnc_tm_get_today_end (struct tm *tm)
 
time64 gnc_time64_get_today_start (void)
 
time64 gnc_time64_get_today_end (void)
 
char * gnc_date_timestamp (void)
 Make a timestamp in YYYYMMDDHHMMSS format. More...
 
void gnc_dow_abbrev (gchar *buf, int buf_len, int dow)
 
#define MIN_BUF_LEN   10
 

Detailed Description

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. Note, however, that other applications, besides just GnuCash, use this file. In particular, GnoTime (gttr.sourcefore.net) uses this file, and this file is formally a part of QOF (qof.sourceforge.net).

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...

Warning
HACK ALERT – the scan and print routines should probably be moved to somewhere else. The engine really isn't involved with things like printing formats. This is needed mostly by the GUI and so on. If a file-io backend needs date handling, it should do it itself, instead of depending on the routines here.
(to be renamed qofdate.h in libqof2.)
Author
Copyright (C) 1997 Robin D. Clark rclar.nosp@m.k@cs.nosp@m..hmc..nosp@m.edu
Copyright (C) 1998-2001,2003 Linas Vepstas linas.nosp@m.@lin.nosp@m.as.or.nosp@m.g

Macro Definition Documentation

◆ MAX_DATE_LENGTH

#define MAX_DATE_LENGTH   34

The maximum length of a string created by the date printers

Definition at line 102 of file gnc-date.h.

◆ qof_date_format_get_format

#define qof_date_format_get_format   qof_date_text_format_get_string
Deprecated:
qof_date_format_get_format has been replaced by qof_date_text_format_get_string

Definition at line 142 of file gnc-date.h.

◆ QOF_UTC_DATE_FORMAT

#define QOF_UTC_DATE_FORMAT   "%Y-%m-%dT%H:%M:%SZ"

UTC date format string.

ConstantsTime 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 115 of file gnc-date.h.

Typedef Documentation

◆ time64

typedef gint64 time64

Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-32 typedef for time_t. Since this stops working in 2038, we define our own:

Definition at line 79 of file gnc-date.h.

Enumeration Type Documentation

◆ 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.

149 {
150  GNCDATE_MONTH_NUMBER,
151  GNCDATE_MONTH_ABBREV,
152  GNCDATE_MONTH_NAME
GNCDateMonthFormat
Definition: gnc-date.h:148

◆ 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 134 of file gnc-date.h.

◆ QofDateFormat

Enum for determining a date format

Enumerator
QOF_DATE_FORMAT_US 

United states: mm/dd/yyyy

QOF_DATE_FORMAT_UK 

Britain: dd/mm/yyyy

QOF_DATE_FORMAT_CE 

Continental Europe: dd.mm.yyyy

QOF_DATE_FORMAT_ISO 

ISO: yyyy-mm-dd

QOF_DATE_FORMAT_LOCALE 

Take from locale information

QOF_DATE_FORMAT_UTC 

UTC: 2004-12-12T23:39:11Z

QOF_DATE_FORMAT_CUSTOM 

Used by the check printing code

QOF_DATE_FORMAT_UNSET 

No Fancy Date Format, use Global

Definition at line 118 of file gnc-date.h.

Function Documentation

◆ dateSeparator()

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 1251 of file gnc-date.c.

1252 {
1253  static char locale_separator = '\0';
1254 
1255  switch (dateFormat)
1256  {
1257  case QOF_DATE_FORMAT_CE:
1258  return '.';
1259  case QOF_DATE_FORMAT_ISO:
1260  case QOF_DATE_FORMAT_UTC:
1261  return '-';
1262  case QOF_DATE_FORMAT_US:
1263  case QOF_DATE_FORMAT_UK:
1264  default:
1265  return '/';
1267  if (locale_separator != '\0')
1268  return locale_separator;
1269  else
1270  {
1271  /* Make a guess */
1272  gchar string[256];
1273  struct tm tm;
1274  time64 secs;
1275  gchar *s;
1276 
1277  secs = gnc_time (NULL);
1278  gnc_localtime_r(&secs, &tm);
1279  qof_strftime(string, sizeof(string), GNC_D_FMT, &tm);
1280 
1281  for (s = string; *s != '\0'; s++)
1282  if (!isdigit(*s))
1283  return (locale_separator = *s);
1284  }
1285  break;
1286  }
1287 
1288  return '\0';
1289 }
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.
Definition: gnc-date.c:260
gsize qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)
Definition: gnc-date.c:1380
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.c:410
gint64 time64
Definition: gnc-date.h:79

◆ gdate_to_timespec()

Timespec gdate_to_timespec ( GDate  d)

Turns a GDate into a Timespec, returning the first second of the day

Definition at line 1699 of file gnc-date.c.

1700 {
1701  gnc_gdate_range_check (&d);
1702  return gnc_dmy2timespec_neutral (g_date_get_day(&d),
1703  g_date_get_month(&d),
1704  g_date_get_year(&d));
1705 }
Timespec gnc_dmy2timespec_neutral(gint day, gint month, gint year)

◆ gnc_ctime()

gchar* gnc_ctime ( const time64 secs)

Return a string representation of a date from a 64-bit time value.

Parameters
secsSeconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)
Returns
A string, which must be freed with g_free(), representing the date in the following format: Thu Nov 24 18:22:48 1986
\0 This is equivalent to the strftime format a b H:M:S Y.

Definition at line 401 of file gnc-date.c.

402 {
403  GDateTime *gdt = gnc_g_date_time_new_from_unix_local (clamp_time (*secs));
404  gchar *string = g_date_time_format (gdt, "%a %b %e %H:%M:%S %Y");
405  g_date_time_unref (gdt);
406  return string;
407 }
GDateTime * gnc_g_date_time_new_from_unix_local(time64 time)
Definition: gnc-date.c:152

◆ gnc_date_get_last_mday()

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 655 of file gnc-date.c.

656 {
657  static int last_day_of_month[2][12] =
658  {
659  /* non leap */ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
660  /* leap */ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
661  };
662 
663  /* Is this a leap year? */
664  if (year % 2000 == 0) return last_day_of_month[1][month-1];
665  if (year % 400 == 0 ) return last_day_of_month[0][month-1];
666  if (year % 4 == 0 ) return last_day_of_month[1][month-1];
667  return last_day_of_month[0][month-1];
668 }

◆ gnc_date_string_to_dateformat()

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!

Returns
FALSE on success, TRUE on failure.

◆ gnc_date_string_to_monthformat()

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!

Returns
FALSE on success, TRUE on failure.

◆ gnc_date_timestamp()

char* gnc_date_timestamp ( void  )

Make a timestamp in YYYYMMDDHHMMSS format.

Returns
A pointer to the generated string.
Note
The caller owns this buffer and must g_free it when done.

Definition at line 1426 of file gnc-date.c.

1427 {
1428  GDateTime *gdt = gnc_g_date_time_new_now_local ();
1429  gchar *timestr = g_date_time_format (gdt, "%Y%m%d%H%M%S");
1430  g_date_time_unref (gdt);
1431  return timestr;
1432 }

◆ gnc_difftime()

gdouble gnc_difftime ( const time64  secs1,
const time64  secs2 
)

Find the difference in seconds between two time values.

Parameters
secs1The first time value, in Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)
secs2The second time value, in Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)
Returns
The difference in seconds between secs1 and secs2. If secs2 is later than secs1 the value will be negative.

Definition at line 432 of file gnc-date.c.

433 {
434  return (double)secs1 - (double)secs2;
435 }

◆ gnc_dmy2timespec()

Timespec gnc_dmy2timespec ( gint  day,
gint  month,
gint  year 
)

Convert a day, month, and year to a Timespec, returning the first second of the day

◆ gnc_dmy2timespec_end()

Timespec gnc_dmy2timespec_end ( gint  day,
gint  month,
gint  year 
)

Same as gnc_dmy2timespec, but last second of the day

◆ gnc_dmy2timespec_neutral()

Timespec gnc_dmy2timespec_neutral ( gint  day,
gint  month,
gint  year 
)

Converts a day, month, and year to a Timespec 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.

◆ gnc_dow_abbrev()

void gnc_dow_abbrev ( gchar *  buf,
int  buf_len,
int  dow 
)

Localized DOW abbreviation.

Parameters
buf_lenat least MIN_BUF_LEN
dowstruct tm semantics: 0=sunday .. 6=saturday

Definition at line 1781 of file gnc-date.c.

1782 {
1783  struct tm my_tm;
1784  int i;
1785 
1786  memset(buf, 0, buf_len);
1787  memset(&my_tm, 0, sizeof(struct tm));
1788  my_tm.tm_wday = dow;
1789  i = qof_strftime(buf, buf_len, "%a", &my_tm);
1790  buf[i] = 0;
1791 }
gsize qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)
Definition: gnc-date.c:1380

◆ gnc_g_date_new_today()

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 1685 of file gnc-date.c.

1686 {
1687  GDateTime *gdt = gnc_g_date_time_new_now_local ();
1688  gint day, month, year;
1689  GDate *result;
1690 
1691  g_date_time_get_ymd (gdt, &year, &month, &day);
1692  result = g_date_new_dmy (day, month, year);
1693  g_date_time_unref (gdt);
1694  g_assert(g_date_valid (result));
1695 
1696  return result;
1697 }

◆ gnc_g_date_time_new_from_timespec_local()

GDateTime* gnc_g_date_time_new_from_timespec_local ( Timespec  tm)

Create a GDateTime from a Timespec.

Parameters
tsA local (int64-based) Timespec
Note
: GDateTimes use microseconds, not nanoseconds, so in theory we lose precision. In practice, there's no portable way to get either.
: Works around the lack of Win32 support in GTimeZone before GLib 2.36.
Returns
A GDateTime pointer. Free it with g_date_time_unref () when you're done with it.

Definition at line 441 of file gnc-date.c.

442 {
443  GDateTime *gdt1 = gnc_g_date_time_new_from_unix_local (ts.tv_sec);
444  double nsecs = ((double)ts.tv_nsec + 0.5)/ 1000000000.0L;
445  GDateTime *gdt2 = NULL;
446  g_return_val_if_fail (gdt1 != NULL, NULL);
447  gdt2 = g_date_time_add_seconds (gdt1, nsecs);
448  g_date_time_unref (gdt1);
449  g_assert (g_date_time_to_unix (gdt2) == ts.tv_sec + (nsecs >= 1.0 ? (gint64)nsecs : 0));
450  return gdt2;
451 }
GDateTime * gnc_g_date_time_new_from_unix_local(time64 time)
Definition: gnc-date.c:152

◆ gnc_g_date_time_new_from_unix_local()

GDateTime* gnc_g_date_time_new_from_unix_local ( time64  time)

Wrapper for g_date_time_new_from_unix_local() that takes special care on windows to take the local time zone into account. On unix, it just calls the g_date function.

Definition at line 152 of file gnc-date.c.

153 {
154  GTimeZone *tz = gnc_g_time_zone_new_local ();
155  GDateTime *gdt = g_date_time_new_from_unix_utc (clamp_time (time));
156  if (gdt)
157  gdt = gnc_g_date_time_adjust_for_dst (gdt, tz);
158  return gdt;
159 }

◆ gnc_gmtime()

struct tm* gnc_gmtime ( const time64 secs)

fill out a time struct from a 64-bit time value

Parameters
secsSeconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)
Returns
A struct tm*, allocated on the heap. Must be freed with gnc_tm_free() The time is UTC.

Definition at line 282 of file gnc-date.c.

283 {
284  struct tm *time;
285  GDateTime *gdt = g_date_time_new_from_unix_utc (clamp_time (*secs));
286  g_return_val_if_fail (gdt != NULL, NULL);
287  time = g_slice_alloc0 (sizeof (struct tm));
288  gnc_g_date_time_fill_struct_tm (gdt, time);
289  g_date_time_unref (gdt);
290  return time;
291 }

◆ gnc_iso8601_to_timespec_gmt()

Timespec gnc_iso8601_to_timespec_gmt ( const gchar *  )

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 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.

Returns
The universal time.

XXX Caution: this routine does not handle strings that specify times before January 1 1970.

◆ gnc_localtime()

struct tm* gnc_localtime ( const time64 secs)

fill out a time struct from a 64-bit time value.

Parameters
secsSeconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment).
Returns
A struct tm*, allocated on the heap. Must be freed with gnc_tm_free(). The time is adjusted for the current local time zone.

Definition at line 243 of file gnc-date.c.

244 {
245  struct tm *time = g_slice_alloc0 (sizeof (struct tm));
246  if (gnc_localtime_r (secs, time) == NULL)
247  {
248  gnc_tm_free (time);
249  return NULL;
250  }
251  return time;
252 }
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.
Definition: gnc-date.c:260
void gnc_tm_free(struct tm *time)
free a struct tm* created with gnc_localtime() or gnc_gmtime()
Definition: gnc-date.c:220

◆ gnc_localtime_r()

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.

Parameters
secsSeconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)
timeA struct tm* for the function to fill. The time is adjusted for the current local time zone.

Definition at line 260 of file gnc-date.c.

261 {
262  guint index = 0;
263  GDateTime *gdt = gnc_g_date_time_new_from_unix_local (clamp_time (*secs));
264  g_return_val_if_fail (gdt != NULL, NULL);
265 
266  gnc_g_date_time_fill_struct_tm (gdt, time);
267  if (g_date_time_is_daylight_savings (gdt))
268  {
269  index = 1;
270  time->tm_isdst = 1;
271  }
272 
273 #ifdef HAVE_STRUCT_TM_GMTOFF
274  time->tm_gmtoff = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND;
275 #endif
276 
277  g_date_time_unref (gdt);
278  return time;
279 }
GDateTime * gnc_g_date_time_new_from_unix_local(time64 time)
Definition: gnc-date.c:152

◆ gnc_mktime()

time64 gnc_mktime ( struct tm *  time)

calculate seconds from the epoch given a time struct

Parameters
timeA struct tm* for the function to fill. The time is understood to be in the current local time zone.
Returns
Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment).

Definition at line 351 of file gnc-date.c.

352 {
353  GDateTime *gdt;
354  time64 secs;
355  normalize_struct_tm (time);
356  gdt = gnc_g_date_time_new_local (time->tm_year + 1900, time->tm_mon,
357  time->tm_mday, time->tm_hour,
358  time->tm_min, (gdouble)(time->tm_sec));
359  if (gdt == NULL)
360  {
361  g_warning("Invalid time passed to gnc_mktime");
362  return -1;
363  }
364  time->tm_mon = time->tm_mon > 0 ? time->tm_mon - 1 : 11;
365  // Watch out: struct tm has wday=0..6 with Sunday=0, but GDateTime has wday=1..7 with Sunday=7.
366  time->tm_wday = g_date_time_get_day_of_week (gdt) % 7;
367  time->tm_yday = g_date_time_get_day_of_year (gdt);
368  time->tm_isdst = g_date_time_is_daylight_savings (gdt);
369 
370 #ifdef HAVE_STRUCT_TM_GMTOFF
371  time->tm_gmtoff = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND;
372 #endif
373 
374  secs = g_date_time_to_unix (gdt);
375  g_date_time_unref (gdt);
376  return secs;
377 }
gint64 time64
Definition: gnc-date.h:79

◆ gnc_print_date()

const char* gnc_print_date ( Timespec  ts)

Convenience; calls through to qof_print_date_dmy_buff(). Return: static global string.

Warning
This routine is not thread-safe, because it uses a single global buffer to store the return value. Use qof_print_date_buff() or qof_print_date() instead.

Definition at line 937 of file gnc-date.c.

938 {
939  static char buff[MAX_DATE_LENGTH];
940  time64 t;
941 
942  memset (buff, 0, sizeof (buff));
943  t = ts.tv_sec + (time64)(ts.tv_nsec / 1000000000.0);
944 
946 
947  return buff;
948 }
#define MAX_DATE_LENGTH
Definition: gnc-date.h:102
gint64 time64
Definition: gnc-date.h:79
size_t qof_print_date_buff(char *buff, size_t len, time64 t)
Definition: gnc-date.c:898

◆ gnc_time()

time64 gnc_time ( time64 tbuf)

get the current local time

Parameters
Atime64* which, if not NULL, will be filled in with the same value as is returned.
Returns
Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)

Definition at line 410 of file gnc-date.c.

411 {
412  GDateTime *gdt = gnc_g_date_time_new_now_local ();
413  time64 secs = g_date_time_to_unix (gdt);
414  g_date_time_unref (gdt);
415  if (tbuf != NULL)
416  *tbuf = secs;
417  return secs;
418 }
gint64 time64
Definition: gnc-date.h:79

◆ gnc_time64_get_day_end()

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.

Definition at line 1737 of file gnc-date.c.

1738 {
1739  struct tm tm;
1740  time64 new_time;
1741 
1742  gnc_tm_get_day_end(&tm, time_val);
1743  new_time = gnc_mktime(&tm);
1744  return new_time;
1745 }
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
Definition: gnc-date.c:351
gint64 time64
Definition: gnc-date.h:79

◆ gnc_time64_get_day_start()

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 last second of that day.

Definition at line 1726 of file gnc-date.c.

1727 {
1728  struct tm tm;
1729  time64 new_time;
1730 
1731  gnc_tm_get_day_start(&tm, time_val);
1732  new_time = gnc_mktime(&tm);
1733  return new_time;
1734 }
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
Definition: gnc-date.c:351
gint64 time64
Definition: gnc-date.h:79

◆ gnc_time64_get_today_end()

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 1772 of file gnc-date.c.

1773 {
1774  struct tm tm;
1775 
1776  gnc_tm_get_day_end(&tm, time(NULL));
1777  return gnc_mktime(&tm);
1778 }
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
Definition: gnc-date.c:351

◆ gnc_time64_get_today_start()

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 1763 of file gnc-date.c.

1764 {
1765  struct tm tm;
1766 
1767  gnc_tm_get_day_start(&tm, time(NULL));
1768  return gnc_mktime(&tm);
1769 }
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
Definition: gnc-date.c:351

◆ gnc_time_utc()

time64 gnc_time_utc ( time64 tbuf)

get the current UTC time

Parameters
Atime64* which, if not NULL, will be filled in with the same value as is returned.
Returns
Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment)

Definition at line 421 of file gnc-date.c.

422 {
423  GDateTime *gdt = g_date_time_new_now_utc ();
424  time64 secs = g_date_time_to_unix (gdt);
425  g_date_time_unref (gdt);
426  if (tbuf != NULL)
427  *tbuf = secs;
428  return secs;
429 }
gint64 time64
Definition: gnc-date.h:79

◆ gnc_timegm()

time64 gnc_timegm ( struct tm *  time)

calculate seconds from the epoch given a time struct

Parameters
timeA struct tm* for the function to fill. The time is understood to be utc.
Returns
Seconds since 00:00:01 UTC 01 January 1970 (negative values are seconds before that moment).

Definition at line 380 of file gnc-date.c.

381 {
382  GDateTime *gdt;
383  time64 secs;
384  normalize_struct_tm (time);
385  gdt = g_date_time_new_utc (time->tm_year + 1900, time->tm_mon,
386  time->tm_mday, time->tm_hour, time->tm_min,
387  (gdouble)(time->tm_sec));
388  if (gdt == NULL)
389  {
390  PERR("Failed to get valid GDateTime with struct tm: %d-%d-%d %d:%d:%d",
391  time->tm_year + 1900, time->tm_mon, time->tm_mday, time->tm_hour,
392  time->tm_min, time->tm_sec);
393  return 0;
394  }
395  secs = g_date_time_to_unix (gdt);
396  g_date_time_unref (gdt);
397  return secs;
398 }
#define PERR(format, args...)
Definition: qoflog.h:232
gint64 time64
Definition: gnc-date.h:79

◆ gnc_timespec2dmy()

void gnc_timespec2dmy ( Timespec  ts,
gint *  day,
gint *  month,
gint *  year 
)

Set the proleptic Gregorian day, month, and year from a Timespec

Parameters
tsinput timespec
dayoutput day, 1 - 31
monthoutput month, 1 - 12
yearoutput year, 0001 - 9999 CE

◆ gnc_timespec_to_iso8601_buff()

gchar* gnc_timespec_to_iso8601_buff ( Timespec  ts,
gchar *  buff 
)

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 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.

◆ gnc_timezone()

glong gnc_timezone ( const struct tm *  tm)

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 time zone offset and daylight savings time, or only daylight savings time! time zone stuff under unix is not standardized and is a big mess.

Definition at line 1621 of file gnc-date.c.

1622 {
1623  g_return_val_if_fail (tm != NULL, 0);
1624 
1625 #ifdef HAVE_STRUCT_TM_GMTOFF
1626  /* tm_gmtoff is seconds *east* of UTC and is
1627  * already adjusted for daylight savings time. */
1628  return -(tm->tm_gmtoff);
1629 #else
1630  {
1631  long tz_seconds;
1632  /* timezone is seconds *west* of UTC and is
1633  * not adjusted for daylight savings time.
1634  * In Spring, we spring forward, wheee! */
1635 # if COMPILER(MSVC)
1636  _get_timezone(&tz_seconds);
1637 # else
1638  tz_seconds = timezone;
1639 # endif
1640  return (long int)(tz_seconds - (tm->tm_isdst > 0 ? 3600 : 0));
1641  }
1642 #endif
1643 }

◆ gnc_tm_free()

void gnc_tm_free ( struct tm *  time)

free a struct tm* created with gnc_localtime() or gnc_gmtime()

Parameters
timeThe struct tm* to be freed.

Definition at line 220 of file gnc-date.c.

221 {
222  g_slice_free1 (sizeof (struct tm), time);
223 }

◆ gnc_tm_get_today_end()

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 1757 of file gnc-date.c.

1758 {
1759  gnc_tm_get_day_end(tm, time(NULL));
1760 }

◆ gnc_tm_get_today_start()

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 1751 of file gnc-date.c.

1752 {
1753  gnc_tm_get_day_start(tm, time(NULL));
1754 }

◆ qof_date_completion_set()

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 741 of file gnc-date.c.

742 {
743  if (dc == QOF_DATE_COMPLETION_THISYEAR ||
745  {
746  dateCompletion = dc;
747  }
748  else
749  {
750  /* hack alert - Use a neutral default. */
751  PERR("non-existent date completion set attempted. Setting current year completion as default");
752  dateCompletion = QOF_DATE_COMPLETION_THISYEAR;
753  }
754 
755  if (backmonths < 0)
756  {
757  backmonths = 0;
758  }
759  else if (backmonths > 11)
760  {
761  backmonths = 11;
762  }
763  dateCompletionBackMonths = backmonths;
764 
765  return;
766 }
#define PERR(format, args...)
Definition: qoflog.h:232

◆ qof_date_format_get()

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.

Returns
: the one of the enumerated date formats.

Definition at line 692 of file gnc-date.c.

693 {
694  return dateFormat;
695 }

◆ qof_date_format_get_string()

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.

Parameters
dfThe date style (us, uk, iso, etc) that should be provided.
Returns
A formatting string that will print a date in the requested style

Definition at line 775 of file gnc-date.c.

776 {
777  switch (df)
778  {
779  case QOF_DATE_FORMAT_US:
780  return "%m/%d/%y";
781  case QOF_DATE_FORMAT_UK:
782  return "%d/%m/%y";
783  case QOF_DATE_FORMAT_CE:
784  return "%d.%m.%y";
785  case QOF_DATE_FORMAT_UTC:
786  return "%Y-%m-%dT%H:%M:%SZ";
787  case QOF_DATE_FORMAT_ISO:
788  return "%Y-%m-%d";
789  case QOF_DATE_FORMAT_UNSET: // use global
790  return qof_date_format_get_string (dateFormat);
792  default:
793  break;
794  };
795  return GNC_D_FMT;
796 }
const gchar * qof_date_format_get_string(QofDateFormat df)
Definition: gnc-date.c:775

◆ qof_date_format_set()

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 708 of file gnc-date.c.

709 {
710  if (df >= DATE_FORMAT_FIRST && df <= DATE_FORMAT_LAST)
711  {
712  prevQofDateFormat = dateFormat;
713  dateFormat = df;
714  }
715  else
716  {
717  /* hack alert - Use a neutral default. */
718  PERR("non-existent date format set attempted. Setting ISO default");
719  prevQofDateFormat = dateFormat;
720  dateFormat = QOF_DATE_FORMAT_ISO;
721  }
722 
723  return;
724 }
#define PERR(format, args...)
Definition: qoflog.h:232

◆ qof_date_text_format_get_string()

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.

Parameters
dfThe date style (us, uk, iso, etc) that should be provided.
Returns
A formatting string that will print a date in the requested style

Definition at line 807 of file gnc-date.c.

808 {
809  switch (df)
810  {
811  case QOF_DATE_FORMAT_US:
812  return "%b %d, %y";
813  case QOF_DATE_FORMAT_UK:
814  case QOF_DATE_FORMAT_CE:
815  return "%d %b, %y";
816  case QOF_DATE_FORMAT_UTC:
817  return "%Y-%m-%dT%H:%M:%SZ";
818  case QOF_DATE_FORMAT_ISO:
819  return "%Y-%b-%d";
820  case QOF_DATE_FORMAT_UNSET: // use global
821  return qof_date_text_format_get_string (dateFormat);
823  default:
824  break;
825  };
826  return GNC_D_FMT;
827 }
const gchar * qof_date_text_format_get_string(QofDateFormat df)
Definition: gnc-date.c:807

◆ qof_print_date()

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 928 of file gnc-date.c.

929 {
930  char buff[MAX_DATE_LENGTH];
931  memset (buff, 0, sizeof (buff));
933  return g_strdup (buff);
934 }
#define MAX_DATE_LENGTH
Definition: gnc-date.h:102
size_t qof_print_date_buff(char *buff, size_t len, time64 t)
Definition: gnc-date.c:898

◆ qof_print_date_buff()

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 898 of file gnc-date.c.

899 {
900  struct tm theTime;
901  time64 bt = clamp_time (t);
902  size_t actual;
903  if (!buff) return 0 ;
904  if (!gnc_localtime_r(&bt, &theTime))
905  return 0;
906 
907  actual = qof_print_date_dmy_buff (buff, len,
908  theTime.tm_mday,
909  theTime.tm_mon + 1,
910  theTime.tm_year + 1900);
911  return actual;
912 }
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.
Definition: gnc-date.c:260
size_t qof_print_date_dmy_buff(gchar *buff, size_t buflen, int day, int month, int year)
gint64 time64
Definition: gnc-date.h:79

◆ qof_print_date_dmy_buff()

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

◆ qof_print_date_time_buff()

size_t qof_print_date_time_buff ( char *  buff,
size_t  len,
time64  secs 
)

Returns the number of bytes printed.

◆ qof_print_gdate()

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 915 of file gnc-date.c.

916 {
917  GDate date;
918  g_date_clear (&date, 1);
919  date = *gd;
920  gnc_gdate_range_check (&date);
921  return qof_print_date_dmy_buff( buf, len,
922  g_date_get_day(&date),
923  g_date_get_month(&date),
924  g_date_get_year(&date) );
925 }
size_t qof_print_date_dmy_buff(gchar *buff, size_t buflen, int day, int month, int year)

◆ qof_scan_date()

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 1243 of file gnc-date.c.

1244 {
1245  return qof_scan_date_internal(buff, day, month, year, dateFormat);
1246 }

◆ qof_strftime()

gsize qof_strftime ( gchar *  buf,
gsize  max,
const gchar *  format,
const struct tm *  tm 
)
Warning
HACK ALERT – the scan and print routines should probably be moved to somewhere else. The engine really isn't involved with things like printing formats. This is needed mostly by the GUI and so on. If a file-io thing needs date handling, it should do it itself, instead of depending on the routines here.qof_strftime calls qof_format_time to print a given time and afterwards tries to put the result into a buffer of fixed size.
Parameters
bufA buffer.
maxThe size of buf in bytes.
formatA format specification in UTF-8.
tmA broken-down time.
Returns
The number of characters written, not include the null byte, if the complete string, including the null byte, fits into the buffer. Otherwise 0.

Definition at line 1380 of file gnc-date.c.

1381 {
1382  gsize convlen, retval;
1383  gchar *convbuf;
1384 
1385  g_return_val_if_fail(buf, 0);
1386  g_return_val_if_fail(max > 0, 0);
1387  g_return_val_if_fail(format, 0);
1388  g_return_val_if_fail(tm, 0);
1389 
1390  convbuf = qof_format_time(format, tm);
1391  if (!convbuf)
1392  {
1393  buf[0] = '\0';
1394  return 0;
1395  }
1396 
1397  convlen = strlen(convbuf);
1398 
1399  if (max <= convlen)
1400  {
1401  /* Ensure only whole characters are copied into the buffer. */
1402  gchar *end = g_utf8_find_prev_char(convbuf, convbuf + max);
1403  g_assert(end != NULL);
1404  convlen = end - convbuf;
1405 
1406  /* Return 0 because the buffer isn't large enough. */
1407  retval = 0;
1408  }
1409  else
1410  {
1411  retval = convlen;
1412  }
1413 
1414  memcpy(buf, convbuf, convlen);
1415  buf[convlen] = '\0';
1416  g_free(convbuf);
1417 
1418  return retval;
1419 }

◆ timespec_abs()

Timespec timespec_abs ( const Timespec *  t)

absolute value, also normalized

Definition at line 622 of file gnc-date.c.

623 {
624  Timespec retval = *t;
625 
626  timespec_normalize(&retval);
627  if (retval.tv_sec < 0)
628  {
629  retval.tv_sec = - retval.tv_sec;
630  retval.tv_nsec = - retval.tv_nsec;
631  }
632 
633  return retval;
634 }

◆ timespec_cmp()

gint timespec_cmp ( const Timespec *  ta,
const Timespec *  tb 
)

comparison: if (ta < tb) -1; else if (ta > tb) 1; else 0;

Definition at line 593 of file gnc-date.c.

594 {
595  Timespec pta, ptb;
596 
597  if (ta == tb) return 0;
598 /* Copy and normalize the copies */
599  pta = *ta;
600  ptb = *tb;
601  timespec_normalize (&pta);
602  timespec_normalize (&ptb);
603 
604  if (pta.tv_sec < ptb.tv_sec) return -1;
605  if (pta.tv_sec > ptb.tv_sec) return 1;
606  if (pta.tv_nsec < ptb.tv_nsec) return -1;
607  if (pta.tv_nsec > ptb.tv_nsec) return 1;
608  return 0;
609 }

◆ timespec_diff()

Timespec timespec_diff ( const Timespec *  ta,
const Timespec *  tb 
)

difference between ta and tb, results are normalized ie tv_sec and tv_nsec of the result have the same size abs(result.tv_nsec) <= 1000000000

Definition at line 612 of file gnc-date.c.

613 {
614  Timespec retval;
615  retval.tv_sec = ta->tv_sec - tb->tv_sec;
616  retval.tv_nsec = ta->tv_nsec - tb->tv_nsec;
617  timespec_normalize(&retval);
618  return retval;
619 }

◆ timespec_equal()

gboolean timespec_equal ( const Timespec *  ta,
const Timespec *  tb 
)

strict equality

Definition at line 576 of file gnc-date.c.

577 {
578  Timespec pta, ptb;
579 
580  if (ta == tb) return TRUE;
581 /* Copy and normalize the copies */
582  pta = *ta;
583  ptb = *tb;
584  timespec_normalize (&pta);
585  timespec_normalize (&ptb);
586 
587  if (pta.tv_sec != ptb.tv_sec) return FALSE;
588  if (pta.tv_nsec != ptb.tv_nsec) return FALSE;
589  return TRUE;
590 }

◆ timespec_now()

Timespec timespec_now ( void  )

Returns the current clock time as a Timespec, taken from time(2).

Definition at line 1654 of file gnc-date.c.

1655 {
1656  Timespec ts;
1657  ts.tv_sec = gnc_time(NULL);
1658  ts.tv_nsec = 0;
1659  return ts;
1660 }
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.c:410

◆ timespec_to_gdate()

GDate timespec_to_gdate ( Timespec  ts)

Turns a Timespec into a GDate

Definition at line 1672 of file gnc-date.c.

1673 {
1674  GDate result;
1675  gint day, month, year;
1676 
1677  g_date_clear (&result, 1);
1678  gnc_timespec2dmy (ts, &day, &month, &year);
1679  g_date_set_dmy (&result, day, month, year);
1680  g_assert(g_date_valid (&result));
1681 
1682  return result;
1683 }
void gnc_timespec2dmy(Timespec ts, gint *day, gint *month, gint *year)

◆ timespecCanonicalDayTime()

Timespec timespecCanonicalDayTime ( Timespec  t)

convert a timepair on a certain day (localtime) to the timepair 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 Timespec.

Definition at line 642 of file gnc-date.c.

643 {
644  struct tm tm;
645  Timespec retval;
646  time64 t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
647  gnc_localtime_r(&t_secs, &tm);
648  gnc_tm_set_day_middle(&tm);
649  retval.tv_sec = gnc_mktime(&tm);
650  retval.tv_nsec = 0;
651  return retval;
652 }
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.
Definition: gnc-date.c:260
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
Definition: gnc-date.c:351
gint64 time64
Definition: gnc-date.h:79

◆ timespecFromTime64()

void timespecFromTime64 ( Timespec *  ts,
time64  t 
)

Turns a time64 into a Timespec

Definition at line 1647 of file gnc-date.c.

1648 {
1649  ts->tv_sec = clamp_time (t);
1650  ts->tv_nsec = 0;
1651 }

◆ timespecToTime64()

time64 timespecToTime64 ( Timespec  ts)

Turns a Timespec into a time64

Definition at line 1663 of file gnc-date.c.

1664 {
1665  return ts.tv_sec;
1666 }

Variable Documentation

◆ gnc_default_strftime_date_format

const char* gnc_default_strftime_date_format

The default date format for use with strftime.

Definition at line 87 of file gnc-date.c.