gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Tue Sep 6 17:46:15 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/c81aeddd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a807d3e6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/68aced36 (commit)



commit c81aeddddec571d0a075709ba864f0b80c472482
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Sep 6 14:36:52 2022 -0700

    Bug 798611 - Date changing when changing timezone by one hour
    
    When getting a date from the date editor anywhere in the program
    set the time to neutral time instead of the beginning of the day
    unless get_date_internal is called with GNC_DATE_EDIT_SHOW_TIME
    in which case the user-provided time is used.

diff --git a/gnucash/gnome-utils/gnc-date-edit.c b/gnucash/gnome-utils/gnc-date-edit.c
index 567a2cd99..d0d7ba8e9 100644
--- a/gnucash/gnome-utils/gnc-date-edit.c
+++ b/gnucash/gnome-utils/gnc-date-edit.c
@@ -296,7 +296,7 @@ gnc_date_edit_popup (GNCDateEdit *gde)
     if (!date_was_valid)
     {
         /* No valid date. Hacky workaround: Instead of crashing we randomly choose today's date. */
-        gnc_tm_get_today_start(&mtm);
+        gnc_tm_get_today_neutral(&mtm);
     }
 
     mtm.tm_mon--;
@@ -307,7 +307,7 @@ gnc_date_edit_popup (GNCDateEdit *gde)
     if (mtm.tm_year >= 1900)
         mtm.tm_year -= 1900;
 
-    gnc_tm_set_day_start(&mtm);
+    gnc_tm_set_day_neutral(&mtm);
 
     /* Set the calendar.  */
     gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), 1);
@@ -1061,7 +1061,7 @@ gnc_date_edit_get_date_internal (GNCDateEdit *gde)
         revert to today's date. Alternatively we can return some value that
         signals that we don't get a valid date, but all callers of this
         function will have to check this. Alas, I'm too lazy to do this here. */
-        gnc_tm_get_today_start(&tm);
+        gnc_tm_get_today_neutral(&tm);
     }
 
     tm.tm_mon--;
@@ -1109,7 +1109,7 @@ gnc_date_edit_get_date_internal (GNCDateEdit *gde)
     }
     else
     {
-        gnc_tm_set_day_start(&tm);
+        gnc_tm_set_day_neutral(&tm);
     }
 
     tm.tm_isdst = -1;

commit a807d3e6b70e89ffb7981bfbbf1ebfd9229be203
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Sep 6 14:35:11 2022 -0700

    Create function gnc_tm_get_today_neutral.
    
    To complement gnc_tm_get_today_begin and gnc_tm_get_today_end.

diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index e7686463e..06916b14f 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1334,6 +1334,12 @@ gnc_tm_get_today_start (struct tm *tm)
     gnc_tm_get_day_start(tm, time(NULL));
 }
 
+void
+gnc_tm_get_today_neutral (struct tm *tm)
+{
+    gnc_tm_get_day_neutral(tm, time(NULL));
+}
+
 void
 gnc_tm_get_today_end (struct tm *tm)
 {
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index d2ec8298e..d2da7be27 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -576,7 +576,7 @@ void gnc_tm_set_day_end (struct tm *tm)
 time64 gnc_time64_get_day_start(time64 time_val);
 
 /** The gnc_time64_get_day_neutral() routine will take the given time in
- *  seconds and adjust it to 10:59am of that day. */
+ *  seconds and adjust it to 10:59:00Z 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
@@ -596,6 +596,10 @@ int gnc_date_get_last_mday (int month, int year);
  *  tm and fills it in with the first second of the today. */
 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 timezone neutral time (10:59:00Z). */
+void   gnc_tm_get_today_neutral(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. */
 void   gnc_tm_get_today_end(struct tm *tm);



Summary of changes:
 gnucash/gnome-utils/gnc-date-edit.c | 8 ++++----
 libgnucash/engine/gnc-date.cpp      | 6 ++++++
 libgnucash/engine/gnc-date.h        | 6 +++++-
 3 files changed, 15 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list