[glib: 1/4] Correct FIXME by implementing a function for converting two digits year
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/4] Correct FIXME by implementing a function for converting two digits year
- Date: Wed, 31 Mar 2021 16:16:17 +0000 (UTC)
commit b4f200291979d698dc40a6ba41983341f3e0d69d
Author: Frederic Martinsons <frederic martinsons sigfox com>
Date: Sun Nov 29 08:01:39 2020 +0100
Correct FIXME by implementing a function for converting two digits year
Signed-off-by: Frederic Martinsons <frederic martinsons sigfox com>
glib/gdate.c | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/glib/gdate.c b/glib/gdate.c
index 253ab6524..c52193ff0 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -1206,6 +1206,22 @@ g_date_prepare_to_parse (const gchar *str,
g_date_fill_parse_tokens (str, pt);
}
+static guint
+convert_twodigit_year (gint y)
+{
+ if (using_twodigit_years && y < 100)
+ {
+ guint two = twodigit_start_year % 100;
+ guint century = (twodigit_start_year / 100) * 100;
+
+ if (y < two)
+ century += 100;
+
+ y += century;
+ }
+ return y;
+}
+
/**
* g_date_set_parse:
* @date: a #GDate to fill in
@@ -1302,16 +1318,8 @@ g_date_set_parse (GDate *d,
{
y += locale_era_adjust;
}
- else if (using_twodigit_years && y < 100)
- {
- guint two = twodigit_start_year % 100;
- guint century = (twodigit_start_year / 100) * 100;
-
- if (y < two)
- century += 100;
-
- y += century;
- }
+
+ y = convert_twodigit_year (y);
}
break;
default:
@@ -1355,18 +1363,8 @@ g_date_set_parse (GDate *d,
m = (pt.n[0]/100) % 100;
day = pt.n[0] % 100;
y = pt.n[0]/10000;
-
- /* FIXME move this into a separate function */
- if (using_twodigit_years && y < 100)
- {
- guint two = twodigit_start_year % 100;
- guint century = (twodigit_start_year / 100) * 100;
-
- if (y < two)
- century += 100;
-
- y += century;
- }
+
+ y = convert_twodigit_year (y);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]