Skip to content

Commit 1e289cb

Browse files
committed
GncDate: Remove pointless normalize_month function.
Suggested by Sherlock.
1 parent 966cef1 commit 1e289cb

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

libgnucash/engine/gnc-date.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ normalize_time_component (int *inner, int *outer, int divisor,
141141
}
142142
}
143143

144-
static void
145-
normalize_month(int *month, int *year)
146-
{
147-
++(*month);
148-
normalize_time_component(month, year, 12, 1);
149-
--(*month);
150-
}
151-
152144
static void
153145
normalize_struct_tm (struct tm* time)
154146
{
@@ -164,20 +156,20 @@ normalize_struct_tm (struct tm* time)
164156
normalize_time_component (&(time->tm_sec), &(time->tm_min), 60, 0);
165157
normalize_time_component (&(time->tm_min), &(time->tm_hour), 60, 0);
166158
normalize_time_component (&(time->tm_hour), &(time->tm_mday), 24, 0);
167-
normalize_month (&(time->tm_mon), &year);
159+
normalize_time_component (&(time->tm_mon), &year, 12, 0);
168160

169161
// auto month_in_range = []int (int m){ return (m + 12) % 12; }
170162
while (time->tm_mday < 1)
171163
{
172-
normalize_month (&(--time->tm_mon), &year);
164+
normalize_time_component (&(--time->tm_mon), &year, 12, 0);
173165
last_day = gnc_date_get_last_mday (time->tm_mon, year);
174166
time->tm_mday += last_day;
175167
}
176168
last_day = gnc_date_get_last_mday (time->tm_mon, year);
177169
while (time->tm_mday > last_day)
178170
{
179171
time->tm_mday -= last_day;
180-
normalize_month(&(++time->tm_mon), &year);
172+
normalize_time_component(&(++time->tm_mon), &year, 12, 0);
181173
last_day = gnc_date_get_last_mday (time->tm_mon, year);
182174
}
183175
time->tm_year = year - 1900;

0 commit comments

Comments
 (0)