diff options
-rw-r--r-- | doc/reference/libeutil/Makefile.am | 3 | ||||
-rw-r--r-- | doc/reference/libeutil/libeutil-sections.txt | 2 | ||||
-rw-r--r-- | e-util/e-misc-utils.c | 86 | ||||
-rw-r--r-- | e-util/e-misc-utils.h | 2 |
4 files changed, 93 insertions, 0 deletions
diff --git a/doc/reference/libeutil/Makefile.am b/doc/reference/libeutil/Makefile.am index 7fee929e74..411f0c8b44 100644 --- a/doc/reference/libeutil/Makefile.am +++ b/doc/reference/libeutil/Makefile.am @@ -62,6 +62,9 @@ GTKDOC_LIBS = \ $(GTKHTML_LIBS) \ $(NULL) +# Extra options to supply to gtkdoc-mkdb +MKDB_OPTIONS = --output-format=xml --sgml-mode + # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt index 4934a95c21..57ccb96ac7 100644 --- a/doc/reference/libeutil/libeutil-sections.txt +++ b/doc/reference/libeutil/libeutil-sections.txt @@ -2252,6 +2252,8 @@ e_weekday_get_prev e_weekday_add_days e_weekday_subtract_days e_weekday_get_days_between +e_weekday_to_tm_wday +e_weekday_from_tm_wday e_flexible_strtod E_ASCII_DTOSTR_BUF_SIZE e_ascii_dtostr diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c index 60ebc6bf79..0f350999f5 100644 --- a/e-util/e-misc-utils.c +++ b/e-util/e-misc-utils.c @@ -1648,6 +1648,92 @@ e_weekday_get_days_between (GDateWeekday weekday1, return n_days; } +/** + * e_weekday_to_tm_wday: + * @weekday: a #GDateWeekday + * + * Converts a #GDateWeekday to the numbering used in + * <structname>struct tm</structname>. + * + * Returns: number of days since Sunday (0 - 6) + **/ +gint +e_weekday_to_tm_wday (GDateWeekday weekday) +{ + gint tm_wday; + + switch (weekday) { + case G_DATE_MONDAY: + tm_wday = 1; + break; + case G_DATE_TUESDAY: + tm_wday = 2; + break; + case G_DATE_WEDNESDAY: + tm_wday = 3; + break; + case G_DATE_THURSDAY: + tm_wday = 4; + break; + case G_DATE_FRIDAY: + tm_wday = 5; + break; + case G_DATE_SATURDAY: + tm_wday = 6; + break; + case G_DATE_SUNDAY: + tm_wday = 0; + break; + default: + g_return_val_if_reached (-1); + } + + return tm_wday; +} + +/** + * e_weekday_from_tm_wday: + * @tm_wday: number of days since Sunday (0 - 6) + * + * Converts a weekday in the numbering used in + * <structname>struct tm</structname> to a #GDateWeekday. + * + * Returns: a #GDateWeekday + **/ +GDateWeekday +e_weekday_from_tm_wday (gint tm_wday) +{ + GDateWeekday weekday; + + switch (tm_wday) { + case 0: + weekday = G_DATE_SUNDAY; + break; + case 1: + weekday = G_DATE_MONDAY; + break; + case 2: + weekday = G_DATE_TUESDAY; + break; + case 3: + weekday = G_DATE_WEDNESDAY; + break; + case 4: + weekday = G_DATE_THURSDAY; + break; + case 5: + weekday = G_DATE_FRIDAY; + break; + case 6: + weekday = G_DATE_SATURDAY; + break; + default: + g_return_val_if_reached (G_DATE_BAD_WEEKDAY); + } + + return weekday; +} + /* Evolution Locks for crash recovery */ static const gchar * get_lock_filename (void) diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h index 20a17b8add..d45f8d34e8 100644 --- a/e-util/e-misc-utils.h +++ b/e-util/e-misc-utils.h @@ -147,6 +147,8 @@ GDateWeekday e_weekday_subtract_days (GDateWeekday weekday, guint n_days); guint e_weekday_get_days_between (GDateWeekday weekday1, GDateWeekday weekday2); +gint e_weekday_to_tm_wday (GDateWeekday weekday); +GDateWeekday e_weekday_from_tm_wday (gint tm_wday); gboolean e_file_lock_create (void); void e_file_lock_destroy (void); |