gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Tue Nov 20 15:14:42 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/e57d4278 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/13f6c4d6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/11af81b5 (commit)



commit e57d4278e8ed6fa6f29db81cc8b6f1e609c54979
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Nov 20 21:13:39 2018 +0100

    Bug 760825 - On duplicating a bill, the entry dates should be set to the bill date, not to the current date - followup
    
    Use neutral time on entry post dates instead of canonical time

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 4f2505b..adb7e26 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -310,7 +310,7 @@ set_gncEntry_date(gpointer data, gpointer user_data)
     time64 new_date = *(time64*) user_data;
     //g_warning("Modifying date for entry with desc=\"%s\"", gncEntryGetDescription(entry));
 
-    gncEntrySetDate(entry, time64CanonicalDayTime (new_date));
+    gncEntrySetDate(entry, gnc_time64_get_day_neutral (new_date));
     /*gncEntrySetDateEntered(entry, *new_date); - don't modify this
      * because apparently it defines the ordering of the entries,
      * which we don't want to change. */
@@ -2756,9 +2756,9 @@ InvoiceWindow * gnc_ui_invoice_duplicate (GtkWindow *parent, GncInvoice *old_inv
 
     // Modify the date to today
     if (new_date)
-        entry_date = time64CanonicalDayTime (gdate_to_time64 (*new_date));
+        entry_date = gnc_time64_get_day_neutral (gdate_to_time64 (*new_date));
     else
-        entry_date = time64CanonicalDayTime (gnc_time (NULL));
+        entry_date = gnc_time64_get_day_neutral (gnc_time (NULL));
     gncInvoiceSetDateOpened(new_invoice, entry_date);
 
     // Also modify the date of all entries to today

commit 13f6c4d6d7e7e20acc74b16045510db70ce7f519
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Nov 20 21:12:32 2018 +0100

    Introduce and use gnc_time64_get_day_neutral
    
    This function complements gnc_time64_get_day_begin/end. There was
    time64CanonicalDayTime but this returned noon of the given day, where we
    want 10:59am in most cases. I haven't changed time64CanonicalDayTime
    directly as that may break assumptions in other parts of the code.
    Instead I have created a new function that can be gradually introduced.

diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index fd394b3..756d12c 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1244,6 +1244,15 @@ gnc_tm_get_day_start (struct tm *tm, time64 time_val)
 }
 
 static void
+gnc_tm_get_day_neutral (struct tm *tm, time64 time_val)
+{
+    /* Get the equivalent time structure */
+    if (!gnc_localtime_r(&time_val, tm))
+        return;
+    gnc_tm_set_day_neutral(tm);
+}
+
+static void
 gnc_tm_get_day_end (struct tm *tm, time64 time_val)
 {
     /* Get the equivalent time structure */
@@ -1264,6 +1273,17 @@ gnc_time64_get_day_start (time64 time_val)
 }
 
 time64
+gnc_time64_get_day_neutral (time64 time_val)
+{
+    struct tm tm;
+    time64 new_time;
+
+    gnc_tm_get_day_neutral(&tm, time_val);
+    new_time = gnc_mktime(&tm);
+    return new_time;
+}
+
+time64
 gnc_time64_get_day_end (time64 time_val)
 {
     struct tm tm;
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index b3dc51e..aed8d0a 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -524,6 +524,20 @@ void gnc_tm_set_day_start (struct tm *tm)
     tm->tm_sec = 0;
 }
 
+/** The gnc_tm_set_day_neutral() inline routine will set the appropriate
+ *  fields in the struct tm to indicate 10:59am of that day.  This
+ *  routine assumes that the contents of the data structure is already
+ *  in normalized form.*/
+static inline
+void gnc_tm_set_day_neutral (struct tm *tm)
+{
+    /* First second of the day */
+    g_return_if_fail (tm != NULL);
+    tm->tm_hour = 10;
+    tm->tm_min = 59;
+    tm->tm_sec = 0;
+}
+
 /** The gnc_tm_set_day_middle() 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
@@ -553,9 +567,13 @@ void gnc_tm_set_day_end (struct tm *tm)
 }
 
 /** The gnc_time64_get_day_start() routine will take the given time in
- *  seconds and adjust it to the last second of that day. */
+ *  seconds and adjust it to the first second of that day. */
 time64 gnc_time64_get_day_start(time64 time_val);
 
+/** The gnc_time64_get_day_netural() routine will take the given time in
+ *  seconds and adjust it to 10:59am of that day. */
+time64 gnc_time64_get_day_neutral(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. */
 time64 gnc_time64_get_day_end(time64 time_val);



Summary of changes:
 gnucash/gnome/dialog-invoice.c |  6 +++---
 libgnucash/engine/gnc-date.cpp | 20 ++++++++++++++++++++
 libgnucash/engine/gnc-date.h   | 20 +++++++++++++++++++-
 3 files changed, 42 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list