[goffice] GOFormat: add functions to query year/month/day
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOFormat: add functions to query year/month/day
- Date: Mon, 10 Jun 2019 00:21:04 +0000 (UTC)
commit 9cc71cd06da3477682d563ae095892e9766bfe05
Author: Morten Welinder <terra gnome org>
Date: Sun Jun 9 20:20:31 2019 -0400
GOFormat: add functions to query year/month/day
ChangeLog | 5 ++++
NEWS | 3 +++
goffice/utils/go-format.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++
goffice/utils/go-format.h | 4 ++++
4 files changed, 72 insertions(+)
---
diff --git a/ChangeLog b/ChangeLog
index 48c7069b..87be1a0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-09 Morten Welinder <terra gnome org>
+
+ * goffice/utils/go-format.c (go_format_has_year)
+ (go_format_has_month) (go_format_has_day): new functions.
+
2019-06-07 Jean Brefort <jean brefort normalesup org>
* goffice/gtk/go-math-editor.c (go_math_editor_class_init): fix signals to
diff --git a/NEWS b/NEWS
index b1452c43..8e4de3ad 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ goffice 0.10.46:
Jean:
* Fix equations edition inside charts.
+Morten:
+ * Add more functions to inspect formats.
+
--------------------------------------------------------------------------
goffice 0.10.45:
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 0adf3bff..ae3effc5 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -417,6 +417,9 @@ struct _GOFormat {
unsigned int date_ybm : 1; /* year, then month. */
unsigned int date_mbd : 1; /* month, then day. */
unsigned int date_dbm : 1; /* day, then month. */
+ unsigned int has_year : 1;
+ unsigned int has_month : 1;
+ unsigned int has_day : 1;
unsigned int has_time : 1;
unsigned int has_hour : 1;
unsigned int has_minute : 1;
@@ -1803,6 +1806,9 @@ go_format_parse_sequential (const char *str, GString *prg,
fmt->u.number.date_ybm = date_ybm;
fmt->u.number.date_mbd = date_mbd;
fmt->u.number.date_dbm = date_dbm;
+ fmt->u.number.has_year = seen_year;
+ fmt->u.number.has_month = seen_month;
+ fmt->u.number.has_day = seen_day;
}
if (seen_time) {
guchar op;
@@ -6561,6 +6567,60 @@ go_format_month_before_day (GOFormat const *fmt)
#endif
+#ifdef DEFINE_COMMON
+/**
+ * go_format_has_year:
+ * @fmt: Format to query
+ *
+ * Returns: TRUE if format is a number format with a year specifier
+ * FALSE otherwise.
+ **/
+gboolean
+go_format_has_year (GOFormat const *fmt)
+{
+ g_return_val_if_fail (fmt != NULL, FALSE);
+
+ return (fmt->typ == GO_FMT_NUMBER &&
+ fmt->u.number.has_year);
+}
+#endif
+
+#ifdef DEFINE_COMMON
+/**
+ * go_format_has_month:
+ * @fmt: Format to query
+ *
+ * Returns: TRUE if format is a number format with a year specifier
+ * FALSE otherwise.
+ **/
+gboolean
+go_format_has_month (GOFormat const *fmt)
+{
+ g_return_val_if_fail (fmt != NULL, FALSE);
+
+ return (fmt->typ == GO_FMT_NUMBER &&
+ fmt->u.number.has_month);
+}
+#endif
+
+#ifdef DEFINE_COMMON
+/**
+ * go_format_has_day:
+ * @fmt: Format to query
+ *
+ * Returns: TRUE if format is a number format with a day-of-month specifier
+ * FALSE otherwise.
+ **/
+gboolean
+go_format_has_day (GOFormat const *fmt)
+{
+ g_return_val_if_fail (fmt != NULL, FALSE);
+
+ return (fmt->typ == GO_FMT_NUMBER &&
+ fmt->u.number.has_day);
+}
+#endif
+
#ifdef DEFINE_COMMON
/**
* go_format_has_hour:
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 0c2a24fe..80a757a0 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -205,6 +205,10 @@ int go_format_is_date (GOFormat const *fmt);
int go_format_is_time (GOFormat const *fmt);
int go_format_month_before_day (GOFormat const *fmt);
+gboolean go_format_has_year (GOFormat const *fmt);
+gboolean go_format_has_month (GOFormat const *fmt);
+gboolean go_format_has_day (GOFormat const *fmt);
+
gboolean go_format_has_hour (GOFormat const *fmt);
gboolean go_format_has_minute (GOFormat const *fmt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]