28 #define __EXTENSIONS__ 37 #ifdef HAVE_LANGINFO_D_FMT 38 # include <langinfo.h> 48 #include <unicode/calendar.h> 51 #include "gnc-date-p.h" 52 #include "gnc-datetime.hpp" 53 #include "gnc-timezone.hpp" 54 #define BOOST_ERROR_CODE_HEADER_ONLY 55 #include <boost/date_time/local_time/local_time.hpp> 57 #define N_(string) string //So that xgettext will find it 59 #ifdef HAVE_LANGINFO_D_FMT 60 # define GNC_D_FMT (nl_langinfo (D_FMT)) 61 # define GNC_D_T_FMT (nl_langinfo (D_T_FMT)) 62 # define GNC_T_FMT (nl_langinfo (T_FMT)) 63 #elif defined(G_OS_WIN32) 64 # define GNC_D_FMT (qof_win32_get_time_format(QOF_WIN32_PICTURE_DATE)) 65 # define GNC_T_FMT (qof_win32_get_time_format(QOF_WIN32_PICTURE_TIME)) 66 # define GNC_D_T_FMT (qof_win32_get_time_format(QOF_WIN32_PICTURE_DATETIME)) 68 # define GNC_D_FMT "%Y-%m-%d" 69 # define GNC_D_T_FMT "%Y-%m-%d %r" 70 # define GNC_T_FMT "%r" 89 static int dateCompletionBackMonths = 6;
92 static QofLogModule log_module = QOF_MOD_ENGINE;
104 auto time =
static_cast<struct tm*
>(calloc(1,
sizeof(
struct tm)));
118 *time =
static_cast<struct tm
>(
GncDateTime(*secs));
121 catch(std::invalid_argument&)
128 normalize_time_component (
int *inner,
int *outer,
int divisor)
135 while (*inner >= divisor)
143 normalize_struct_tm (
struct tm* time)
145 gint year = time->tm_year + 1900;
151 if (year < 1400) year += 1400;
152 if (year > 9999) year %= 10000;
154 normalize_time_component (&(time->tm_sec), &(time->tm_min), 60);
155 normalize_time_component (&(time->tm_min), &(time->tm_hour), 60);
156 normalize_time_component (&(time->tm_hour), &(time->tm_mday), 24);
157 normalize_time_component (&(time->tm_mon), &year, 12);
160 while (time->tm_mday < 1)
162 normalize_time_component (&(--time->tm_mon), &year, 12);
164 time->tm_mday += last_day;
167 while (time->tm_mday > last_day)
169 time->tm_mday -= last_day;
170 normalize_time_component(&(++time->tm_mon), &year, 12);
173 time->tm_year = year - 1900;
182 auto time =
static_cast<struct tm*
>(calloc(1,
sizeof(
struct tm)));
186 catch(std::invalid_argument&)
197 static int cached_result = 0;
201 UErrorCode err = U_ZERO_ERROR;
202 auto cal = icu::Calendar::createInstance (err);
205 PERR(
"ICU error: %s\n", u_errorName (err));
210 cached_result = cal->getFirstDayOfWeek (err);
214 return cached_result;
222 normalize_struct_tm (time);
224 *time =
static_cast<struct tm
>(gncdt);
225 return static_cast<time64>(gncdt);
227 catch(std::invalid_argument&)
238 normalize_struct_tm(time);
240 *time =
static_cast<struct tm
>(gncdt);
241 time->tm_sec -= gncdt.
offset();
242 normalize_struct_tm(time);
243 #ifdef HAVE_STRUcT_TM_GMTOFF 248 catch(std::invalid_argument&)
264 auto time =
static_cast<time64>(gncdt);
273 PWARN (
"gnc_difftime is deprecated");
274 return (
double)secs1 - (double)secs2;
311 if (!strcmp(fmt_str,
"us"))
313 else if (!strcmp(fmt_str,
"uk"))
315 else if (!strcmp(fmt_str,
"ce"))
317 else if (!strcmp(fmt_str,
"utc"))
319 else if (!strcmp(fmt_str,
"iso"))
321 else if (!strcmp(fmt_str,
"locale"))
323 else if (!strcmp(fmt_str,
"custom"))
325 else if (!strcmp(fmt_str,
"unset"))
337 switch (static_cast<uint8_t>(format))
339 case GNCDATE_MONTH_NUMBER:
341 case GNCDATE_MONTH_ABBREV:
343 case GNCDATE_MONTH_NAME:
356 if (!strcmp(fmt_str,
"number"))
357 *format = GNCDATE_MONTH_NUMBER;
358 else if (!strcmp(fmt_str,
"abbrev"))
359 *format = GNCDATE_MONTH_ABBREV;
360 else if (!strcmp(fmt_str,
"name"))
361 *format = GNCDATE_MONTH_NAME;
374 auto sstr = gncdt.
format(format);
376 char* cstr =
static_cast<char*
>(malloc(sstr.length() + 1));
377 memset(cstr, 0, sstr.length() + 1);
378 strncpy(cstr, sstr.c_str(), sstr.length());
381 catch(std::runtime_error& err)
383 PWARN(
"Error processing time64 %" PRId64
": %s", time, err.what());
386 catch(std::logic_error& err)
388 PWARN(
"Error processing time64 %" PRId64
": %s", time, err.what());
407 gnc_tm_set_day_middle(&tm);
414 static int last_day_of_month[12] =
415 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
417 g_assert(month >= 0 && month < 12);
422 return last_day_of_month[month] +
423 (month == 1 && year % 4 == 0 && !(year % 100 == 0 && year % 400 != 0) ?
435 auto dfi{
static_cast<uint8_t
>(df)};
436 if (dfi >= DATE_FORMAT_FIRST && dfi <= DATE_FORMAT_LAST)
438 prevQofDateFormat = dateFormat;
444 PERR(
"non-existent date format set attempted. Setting ISO default");
445 prevQofDateFormat = dateFormat;
477 PERR(
"non-existent date completion set attempted. Setting current year completion as default");
485 else if (backmonths > 11)
489 dateCompletionBackMonths = backmonths;
512 return "%Y-%m-%dT%H:%M:%SZ";
534 return "%Y-%m-%dT%H:%M:%SZ";
553 GncDate date(year, month, day);
555 strncpy(buff, str.c_str(), len);
556 if (str.length() >= len)
557 buff[len - 1] =
'\0';
559 catch(std::logic_error& err)
561 PWARN(
"Error processing year-month-day %d-%d-%d: %s",
562 year, month, day, err.what());
564 catch(std::runtime_error& err)
566 PWARN(
"Error processing year-month-day %d-%d-%d: %s",
567 year, month, day, err.what());
581 strncpy(buff, str.c_str(), len);
582 if (str.length() >= len)
583 buff[len - 1] =
'\0';
585 catch(std::logic_error& err)
587 PWARN(
"Error processing time64 %" PRId64
": %s", t, err.what());
589 catch(std::runtime_error& err)
591 PWARN(
"Error processing time64 %" PRId64
": %s", t, err.what());
600 g_date_clear (&date, 1);
603 g_date_get_day(&date),
604 g_date_get_month(&date),
605 g_date_get_year(&date) );
612 memset (buff, 0,
sizeof (buff));
614 return g_strdup (buff);
622 floordiv(
int a,
int b)
630 return - ((-a - 1) / b) - 1;
639 static inline std::string
640 normalize_format (
const std::string& format)
643 std::string normalized;
645 format.begin(), format.end(), back_inserter(normalized),
647 bool r = (is_pct && (e ==
'E' || e ==
'O' || e ==
'-'));
677 qof_scan_date_internal (
const char *buff,
int *day,
int *month,
int *year,
680 char *dupe, *tmp, *first_field, *second_field, *third_field;
681 int iday, imonth, iyear;
682 int now_day, now_month, now_year;
686 if (!buff)
return(FALSE);
691 || strptime (buff,
"%Y-%m-%d", &utc))
694 *month = utc.tm_mon + 1;
695 *year = utc.tm_year + 1900;
703 dupe = g_strdup (buff);
706 first_field =
nullptr;
707 second_field =
nullptr;
708 third_field =
nullptr;
713 static const char *delims =
".,-+/\\()년월年月 ";
715 first_field = strtok (tmp, delims);
718 second_field = strtok (
nullptr, delims);
721 third_field = strtok (
nullptr, delims);
731 now_day = now->tm_mday;
732 now_month = now->tm_mon + 1;
733 now_year = now->tm_year + 1900;
742 switch (which_format)
749 memset(&thetime, -1,
sizeof(
struct tm));
750 char *strv = strptime (buff, normalize_format(GNC_D_FMT).c_str(),
759 iyear = thetime.tm_year + 1900;
760 iday = thetime.tm_mday;
761 imonth = thetime.tm_mon + 1;
763 else if (second_field)
766 if (thetime.tm_year == -1)
769 iday = thetime.tm_mday;
770 imonth = thetime.tm_mon + 1;
772 else if (thetime.tm_mon != -1)
775 imonth = atoi(first_field);
776 iday = atoi(second_field);
781 iday = atoi(first_field);
782 imonth = atoi(second_field);
785 else if (first_field)
787 iday = atoi(first_field);
795 iday = atoi(first_field);
796 imonth = atoi(second_field);
797 iyear = atoi(third_field);
799 else if (second_field)
801 iday = atoi(first_field);
802 imonth = atoi(second_field);
804 else if (first_field)
806 iday = atoi(first_field);
812 iyear = atoi(first_field);
813 imonth = atoi(second_field);
814 iday = atoi(third_field);
816 else if (second_field)
818 imonth = atoi(first_field);
819 iday = atoi(second_field);
821 else if (first_field)
823 iday = atoi(first_field);
830 imonth = atoi(first_field);
831 iday = atoi(second_field);
832 iyear = atoi(third_field);
834 else if (second_field)
836 imonth = atoi(first_field);
837 iday = atoi(second_field);
839 else if (first_field)
841 iday = atoi(first_field);
848 if ((imonth == 0) || (iday == 0))
851 if ((12 < imonth) || (31 < iday))
866 if ((which_format != prevQofDateFormat) &&
867 qof_scan_date_internal(buff, day, month, year, prevQofDateFormat))
871 if ((12 < imonth) && (12 >= iday))
901 iyear = now_year - floordiv(imonth - now_month +
902 dateCompletionBackMonths, 12);
909 iyear += ((int) ((now_year + 50 - iyear) / 100)) * 100;
911 if (year) *year = iyear;
912 if (month) *month = imonth;
913 if (day) *day = iday;
920 return qof_scan_date_internal(buff, day, month, year, dateFormat);
928 static char locale_separator =
'\0';
942 if (locale_separator !=
'\0')
943 return locale_separator;
954 auto normalized_fmt =
956 qof_strftime(
string,
sizeof(
string), normalized_fmt.c_str(), &tm);
958 for (s =
string; *s !=
'\0'; s++)
960 return (locale_separator = *s);
970 qof_time_format_from_utf8(
const gchar *utf8_format)
973 GError *error =
nullptr;
975 retval = g_locale_from_utf8(utf8_format, -1,
nullptr,
nullptr, &error);
979 g_warning(
"Could not convert format '%s' from UTF-8: %s", utf8_format,
987 qof_formatted_time_to_utf8(
const gchar *locale_string)
990 GError *error =
nullptr;
992 retval = g_locale_to_utf8(locale_string, -1,
nullptr,
nullptr, &error);
996 g_warning(
"Could not convert '%s' to UTF-8: %s", locale_string,
1005 qof_format_time(
const gchar *format,
const struct tm *tm)
1007 gchar *locale_format, *tmpbuf, *retval;
1008 gsize tmplen, tmpbufsize;
1010 g_return_val_if_fail(format, 0);
1011 g_return_val_if_fail(tm, 0);
1013 locale_format = qof_time_format_from_utf8(format);
1017 tmpbufsize = MAX(128, strlen(locale_format) * 2);
1020 tmpbuf =
static_cast<gchar*
>(g_malloc(tmpbufsize));
1026 tmplen = strftime(tmpbuf, tmpbufsize, locale_format, tm);
1028 if (tmplen == 0 && tmpbuf[0] !=
'\0')
1033 if (tmpbufsize > 65536)
1035 g_warning(
"Maximum buffer size for qof_format_time " 1036 "exceeded: giving up");
1037 g_free(locale_format);
1047 g_free(locale_format);
1049 retval = qof_formatted_time_to_utf8(tmpbuf);
1056 qof_strftime(gchar *buf, gsize max,
const gchar *format,
const struct tm *tm)
1058 gsize convlen, retval;
1061 g_return_val_if_fail(buf, 0);
1062 g_return_val_if_fail(max > 0, 0);
1063 g_return_val_if_fail(format, 0);
1064 g_return_val_if_fail(tm, 0);
1066 convbuf = qof_format_time(format, tm);
1073 convlen = strlen(convbuf);
1078 gchar *end = g_utf8_find_prev_char(convbuf, convbuf + max);
1079 g_assert(end !=
nullptr);
1080 convlen = end - convbuf;
1090 memcpy(buf, convbuf, convlen);
1091 buf[convlen] =
'\0';
1104 return g_strdup(timestamp.c_str());
1114 #define ISO_DATE_FORMAT "%d-%d-%d %d:%d:%lf%s" 1118 if (!cstr)
return INT64_MAX;
1122 return static_cast<time64>(gncdt);
1124 catch(std::logic_error& err)
1126 PWARN(
"Error processing %s: %s", cstr, err.what());
1129 catch(std::runtime_error& err)
1131 PWARN(
"Error processing time64 %s: %s", cstr, err.what());
1142 if (!buff)
return nullptr;
1148 memset(buff, 0, sstr.length() + 1);
1149 strncpy(buff, sstr.c_str(), sstr.length());
1150 return buff + sstr.length();
1152 catch(std::logic_error& err)
1154 PWARN(
"Error processing time64 %" PRId64
": %s", time, err.what());
1157 catch(std::runtime_error& err)
1159 PWARN(
"Error processing time64 %" PRId64
": %s", time, err.what());
1164 #define THIRTY_TWO_YEARS 0x3c30fc00LL 1167 gnc_dmy2time64_internal (
int day,
int month,
int year, DayPart day_part)
1171 auto date =
GncDate(year, month, day);
1174 catch(
const std::logic_error& err)
1176 PWARN(
"Date computation error from Y-M-D %d-%d-%d: %s",
1177 year, month, day, err.what());
1180 catch(
const std::runtime_error& err)
1182 PWARN(
"Date computation error from Y-M-D %d-%d-%d: %s",
1183 year, month, day, err.what());
1191 return gnc_dmy2time64_internal (day, month, year, DayPart::start);
1197 return gnc_dmy2time64_internal (day, month, year, DayPart::end);
1203 return gnc_dmy2time64_internal (day, month, year, DayPart::neutral);
1215 g_date_clear (&result, 1);
1217 auto date = time.date().year_month_day();
1218 g_date_set_dmy (&result, date.day, static_cast<GDateMonth>(date.month),
1220 g_assert(g_date_valid (&result));
1229 auto month =
static_cast<GDateMonth
>(ymd.month);
1230 auto result = g_date_new_dmy (ymd.day, month, ymd.year);
1231 g_assert(g_date_valid (result));
1239 g_date_set_julian (gd, g_date_get_julian (today));
1240 g_date_free (today);
1248 g_date_set_dmy (gd, tm.tm_mday,
1249 static_cast<GDateMonth>(tm.tm_mon + 1),
1256 g_date_get_month(&d),
1257 g_date_get_year(&d));
1261 gnc_tm_get_day_start (
struct tm *tm,
time64 time_val)
1266 gnc_tm_set_day_start(tm);
1272 auto time_val{gnc_dmy2time64_internal(tm->tm_mday, tm->tm_mon + 1,
1273 tm->tm_year + 1900, DayPart::neutral)};
1278 gnc_tm_get_day_neutral (
struct tm *tm,
time64 time_val)
1287 gnc_tm_get_day_end (
struct tm *tm,
time64 time_val)
1292 gnc_tm_set_day_end(tm);
1301 gnc_tm_get_day_start(&tm, time_val);
1311 return gnc_dmy2time64_internal(tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900,
1321 gnc_tm_get_day_end(&tm, time_val);
1331 gnc_tm_get_day_start(tm,
gnc_time(
nullptr));
1337 gnc_tm_get_day_neutral(tm,
gnc_time(
nullptr));
1343 gnc_tm_get_day_end(tm,
gnc_time(
nullptr));
1351 gnc_tm_get_day_start(&tm,
gnc_time(
nullptr));
1360 gnc_tm_get_day_end(&tm,
gnc_time(
nullptr));
1370 memset(buf, 0, buf_len);
1371 memset(&my_tm, 0,
sizeof(
struct tm));
1372 my_tm.tm_wday = dow;
1382 time64_boxed_copy_func (
Time64 *in_time64)
1385 *newvalue = *in_time64;
1391 time64_boxed_free_func (
Time64 *in_time64)
1396 G_DEFINE_BOXED_TYPE (
Time64,
time64, time64_boxed_copy_func, time64_boxed_free_func)
1403 return (g_date_compare( (GDate*)gda, (GDate*)gdb ) == 0 ? TRUE : FALSE);
1409 gint val = (g_date_get_year( (GDate*)gd ) * 10000)
1410 + (g_date_get_month( (GDate*)gd ) * 100)
1411 + g_date_get_day( (GDate*)gd );
1412 return g_int_hash( &val );
1424 g_date_to_struct_tm (date, &stm);
1438 g_date_to_struct_tm(date, &stm);
1456 g_date_set_day(date, 1);
1470 g_date_set_day(date, 1);
1471 g_date_add_months(date, 1);
1474 g_date_subtract_days(date, 1);
1487 g_date_set_day(date, 1);
1488 g_date_subtract_months(date, 1);
1502 g_date_set_day(date, 1);
1503 g_date_subtract_days(date, 1);
1514 g_date_set_day(date, 1);
1517 months = (g_date_get_month(date) - G_DATE_JANUARY) % 3;
1518 g_date_subtract_months(date, months);
1524 const GDateMonth months[] = {G_DATE_MARCH, G_DATE_JUNE,
1525 G_DATE_SEPTEMBER, G_DATE_DECEMBER};
1526 const GDateDay days[] = {31, 30, 30, 31};
1527 int quarter = (g_date_get_month (date) - 1) / 3;
1529 g_date_set_month (date, months[quarter]);
1530 g_date_set_day (date, days[quarter]);
1536 g_date_subtract_months(date, 3);
1543 g_date_subtract_months(date, 3);
1552 g_date_set_month(date, G_DATE_JANUARY);
1553 g_date_set_day(date, 1);
1559 g_date_set_month(date, G_DATE_DECEMBER);
1560 g_date_set_day(date, 31);
1567 g_date_subtract_years(date, 1);
1574 g_date_subtract_years(date, 1);
1581 const GDate *fy_end)
1586 g_return_if_fail(date);
1587 g_return_if_fail(fy_end);
1591 g_date_set_year(&temp, g_date_get_year(date));
1594 new_fy = (g_date_compare(date, &temp) > 0);
1598 g_date_add_days(date, 1);
1600 g_date_subtract_years(date, 1);
1605 const GDate *fy_end)
1610 g_return_if_fail(date);
1611 g_return_if_fail(fy_end);
1615 g_date_set_year(&temp, g_date_get_year(date));
1618 new_fy = (g_date_compare(date, &temp) > 0);
1623 g_date_add_years(date, 1);
1628 const GDate *fy_end)
1630 g_return_if_fail(date);
1631 g_return_if_fail(fy_end);
1634 g_date_subtract_years(date, 1);
1639 const GDate *fy_end)
1641 g_return_if_fail(date);
1642 g_return_if_fail(fy_end);
1645 g_date_subtract_years(date, 1);
1649 gnc_date_load_funcs (
void)
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...
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 represe...
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 ...
std::string format_iso8601() const
Format the GncDateTime into a gnucash-style iso8601 string in UTC.
Used by the check printing code.
gchar dateSeparator(void)
dateSeparator Return the field separator for the current date format
Date and Time handling routines.
gboolean gnc_date_string_to_monthformat(const gchar *format_string, GNCDateMonthFormat *format)
Converts the month format to a printable string.
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 ...
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...
const char * gnc_date_dateformat_to_string(QofDateFormat format)
The string->value versions return FALSE on success and TRUE on failure.
char * gnc_date_timestamp(void)
Make a timestamp in YYYYMMDDHHMMSS format.
QofDateCompletion
Enum for date completion modes (for dates entered without year)
gint gnc_gdate_equal(gconstpointer gda, gconstpointer gdb)
Compares two GDate*'s for equality; useful for using GDate*'s as GHashTable keys. ...
#define QOF_UTC_DATE_FORMAT
Constants.
Continental Europe: dd.mm.yyyy.
guint gnc_gdate_hash(gconstpointer gd)
Provides a "hash" of a GDate* value; useful for using GDate*'s as GHashTable keys.
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...
size_t qof_print_gdate(char *buf, size_t bufflen, const GDate *gd)
Convenience; calls through to qof_print_date_dmy_buff().
No Fancy Date Format, use Global.
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.
void gnc_gdate_set_today(GDate *gd)
Set a GDate to the current day.
GDate time64_to_gdate(time64 t)
Returns the GDate in which the time64 occurs.
long offset() const
Obtain the UTC offset in seconds.
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 fa...
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 se...
gnc_ymd year_month_day() const
Get the year, month, and day from the date as a gnc_ymd.
int gnc_date_get_last_mday(int month, int year)
Get the numerical last date of the month.
const char * gnc_default_strftime_date_format
The default date format for use with strftime.
#define PERR(format, args...)
Log a serious error.
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_T...
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.
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...
void gnc_tm_free(struct tm *time)
free a struct tm* created with gnc_localtime() or gnc_gmtime()
#define PWARN(format, args...)
Log a warning.
QofDateFormat qof_date_format_get(void)
The qof_date_format_get routine returns the date format that the date printing will use when printing...
use sliding 12-month window
char * qof_print_date(time64 secs)
Convenience; calls through to qof_print_date_dmy_buff().
static std::string timestamp()
Get an undelimited string representing the current date and time.
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 fal...
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 fa...
char * gnc_print_time64(time64 time, const char *format)
print a time64 as a date string per format
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...
void gnc_dow_abbrev(gchar *buf, int buf_len, int dow)
Localized DOW abbreviation.
UTC: 2004-12-12T23:39:11Z.
time64 gnc_time64_get_today_start(void)
The gnc_time64_get_today_start() routine returns a time64 value corresponding to the first second of ...
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
GNCDateMonthFormat
This is how to format the month, as a number, an abbreviated string, or the full name.
time64 gnc_timegm(struct tm *time)
calculate seconds from the epoch given a time struct
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
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...
struct tm * gnc_localtime(const time64 *secs)
fill out a time struct from a 64-bit time value.
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...
gdouble gnc_difftime(const time64 secs1, const time64 secs2)
Find the difference in seconds between two time values (deprecated)
std::string format(const char *format) const
Format the GncDateTime into a std::string.
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_year_end(GDate *date)
This function modifies a GDate to set it to the last day of the year in which it falls.
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...
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 v...
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
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...
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 t...
time64 gnc_dmy2time64_end(gint day, gint month, gint year)
Same as gnc_dmy2time64, but last second of the day.
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 whic...
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...
time64 gnc_time64_get_today_end(void)
The gnc_time64_get_today_end() routine returns a time64 value corresponding to the last second of tod...
struct tm * gnc_gmtime(const time64 *secs)
fill out a time struct from a 64-bit time value
time64 gnc_time(time64 *tbuf)
get the current time
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
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 ...
char * gnc_ctime(const time64 *secs)
Return a string representation of a date from a 64-bit time value.
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 se...
struct tm utc_tm() const
Obtain a struct tm representing the time in UTC.
Take from locale information.
void qof_date_format_set(QofDateFormat df)
The qof_date_format_set() routine sets date format to one of US, UK, CE, OR ISO.
time64 time64CanonicalDayTime(time64 t)
convert a time64 on a certain day (localtime) to the time64 representing midday on that day...
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 secon...
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 indic...
gboolean gnc_date_string_to_dateformat(const gchar *format_string, QofDateFormat *format)
Converts the date format to a printable string.
const gchar * qof_date_format_get_string(QofDateFormat df)
This function returns a strftime formatting string for printing an all numeric date (e...
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...
char * 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-860...
QofDateFormat
Enum for determining a date format.
United states: mm/dd/yyyy.
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...
gint gnc_start_of_week(void)
returns an integer corresponding to locale start of week
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...
size_t qof_print_date_buff(char *buff, size_t buflen, time64 secs)
Convenience: calls through to qof_print_date_dmy_buff().
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:0...
GDate * gnc_g_date_new_today()
Returns a newly allocated date of the current clock time, taken from time(2).
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 f...