gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Dec 8 16:56:41 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/6bc12898 (commit)
via https://github.com/Gnucash/gnucash/commit/1e289cb2 (commit)
via https://github.com/Gnucash/gnucash/commit/966cef19 (commit)
from https://github.com/Gnucash/gnucash/commit/5005c3ca (commit)
commit 6bc12898a8ad52a2338054115ae64f810a1e3028
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Dec 8 13:49:28 2023 -0800
GncDate: Remove now-superfluous base parameter.
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 4d5e651744..2d96648a25 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -126,15 +126,14 @@ gnc_localtime_r (const time64 *secs, struct tm* time)
}
static void
-normalize_time_component (int *inner, int *outer, int divisor,
- int base)
+normalize_time_component (int *inner, int *outer, int divisor)
{
- while (*inner < base)
+ while (*inner < 0)
{
--(*outer);
*inner += divisor;
}
- while (*inner >= divisor + base)
+ while (*inner >= divisor)
{
++(*outer);
*inner -= divisor;
@@ -153,15 +152,15 @@ normalize_struct_tm (struct tm* time)
if (year < 1400) year += 1400;
if (year > 9999) year %= 10000;
- normalize_time_component (&(time->tm_sec), &(time->tm_min), 60, 0);
- normalize_time_component (&(time->tm_min), &(time->tm_hour), 60, 0);
- normalize_time_component (&(time->tm_hour), &(time->tm_mday), 24, 0);
- normalize_time_component (&(time->tm_mon), &year, 12, 0);
+ normalize_time_component (&(time->tm_sec), &(time->tm_min), 60);
+ normalize_time_component (&(time->tm_min), &(time->tm_hour), 60);
+ normalize_time_component (&(time->tm_hour), &(time->tm_mday), 24);
+ normalize_time_component (&(time->tm_mon), &year, 12);
// auto month_in_range = []int (int m){ return (m + 12) % 12; }
while (time->tm_mday < 1)
{
- normalize_time_component (&(--time->tm_mon), &year, 12, 0);
+ normalize_time_component (&(--time->tm_mon), &year, 12);
last_day = gnc_date_get_last_mday (time->tm_mon, year);
time->tm_mday += last_day;
}
@@ -169,7 +168,7 @@ normalize_struct_tm (struct tm* time)
while (time->tm_mday > last_day)
{
time->tm_mday -= last_day;
- normalize_time_component(&(++time->tm_mon), &year, 12, 0);
+ normalize_time_component(&(++time->tm_mon), &year, 12);
last_day = gnc_date_get_last_mday (time->tm_mon, year);
}
time->tm_year = year - 1900;
commit 1e289cb2b812413ea706fdc7dba9a259da70e3a7
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Dec 8 13:47:24 2023 -0800
GncDate: Remove pointless normalize_month function.
Suggested by Sherlock.
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index f8c45fa689..4d5e651744 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -141,14 +141,6 @@ normalize_time_component (int *inner, int *outer, int divisor,
}
}
-static void
-normalize_month(int *month, int *year)
-{
- ++(*month);
- normalize_time_component(month, year, 12, 1);
- --(*month);
-}
-
static void
normalize_struct_tm (struct tm* time)
{
@@ -164,12 +156,12 @@ normalize_struct_tm (struct tm* time)
normalize_time_component (&(time->tm_sec), &(time->tm_min), 60, 0);
normalize_time_component (&(time->tm_min), &(time->tm_hour), 60, 0);
normalize_time_component (&(time->tm_hour), &(time->tm_mday), 24, 0);
- normalize_month (&(time->tm_mon), &year);
+ normalize_time_component (&(time->tm_mon), &year, 12, 0);
// auto month_in_range = []int (int m){ return (m + 12) % 12; }
while (time->tm_mday < 1)
{
- normalize_month (&(--time->tm_mon), &year);
+ normalize_time_component (&(--time->tm_mon), &year, 12, 0);
last_day = gnc_date_get_last_mday (time->tm_mon, year);
time->tm_mday += last_day;
}
@@ -177,7 +169,7 @@ normalize_struct_tm (struct tm* time)
while (time->tm_mday > last_day)
{
time->tm_mday -= last_day;
- normalize_month(&(++time->tm_mon), &year);
+ normalize_time_component(&(++time->tm_mon), &year, 12, 0);
last_day = gnc_date_get_last_mday (time->tm_mon, year);
}
time->tm_year = year - 1900;
commit 966cef19aa3faaf74c8b9cad3386c2e9314d6800
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Dec 8 13:45:04 2023 -0800
Bug 799156 - normalize_struct_tm() does not normalize seconds,...
minutes, and hours correctly.
Fix proposed by Sherlock.
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index b5f2acb948..f8c45fa689 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -126,7 +126,7 @@ gnc_localtime_r (const time64 *secs, struct tm* time)
}
static void
-normalize_time_component (int *inner, int *outer, unsigned int divisor,
+normalize_time_component (int *inner, int *outer, int divisor,
int base)
{
while (*inner < base)
@@ -134,7 +134,7 @@ normalize_time_component (int *inner, int *outer, unsigned int divisor,
--(*outer);
*inner += divisor;
}
- while (*inner > static_cast<gint>(divisor))
+ while (*inner >= divisor + base)
{
++(*outer);
*inner -= divisor;
Summary of changes:
libgnucash/engine/gnc-date.cpp | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
More information about the gnucash-changes
mailing list