Commit 5e9bdd45 authored by Matthew Barnes's avatar Matthew Barnes
Browse files

Add e_get_next_weekday() and e_get_prev_weekday().

These just cycle over the GDateWeekday enum.

Trivial functions, but they help make loops a little easier to read.
parent 8a3453fe
......@@ -2247,6 +2247,8 @@ e_strftime_fix_am_pm
e_utf8_strftime_fix_am_pm
e_get_month_name
e_get_weekday_name
e_get_next_weekday
e_get_prev_weekday
e_flexible_strtod
E_ASCII_DTOSTR_BUF_SIZE
e_ascii_dtostr
......
......@@ -1495,6 +1495,94 @@ e_get_weekday_name (GDateWeekday weekday,
return abbreviated ? abbr_names[weekday] : full_names[weekday];
}
/**
* e_get_next_weekday:
* @weekday: a #GDateWeekday
*
* Returns the #GDateWeekday after @weekday.
*
* Returns: the day after @weekday
**/
GDateWeekday
e_get_next_weekday (GDateWeekday weekday)
{
GDateWeekday next;
/* Verbose for readability. */
switch (weekday) {
case G_DATE_MONDAY:
next = G_DATE_TUESDAY;
break;
case G_DATE_TUESDAY:
next = G_DATE_WEDNESDAY;
break;
case G_DATE_WEDNESDAY:
next = G_DATE_THURSDAY;
break;
case G_DATE_THURSDAY:
next = G_DATE_FRIDAY;
break;
case G_DATE_FRIDAY:
next = G_DATE_SATURDAY;
break;
case G_DATE_SATURDAY:
next = G_DATE_SUNDAY;
break;
case G_DATE_SUNDAY:
next = G_DATE_MONDAY;
break;
default:
next = G_DATE_BAD_WEEKDAY;
break;
}
return next;
}
/**
* e_get_prev_weekday:
* @weekday: a #GDateWeekday
*
* Returns the #GDateWeekday before @weekday.
*
* Returns: the day before @weekday
**/
GDateWeekday
e_get_prev_weekday (GDateWeekday weekday)
{
GDateWeekday prev;
/* Verbose for readability. */
switch (weekday) {
case G_DATE_MONDAY:
prev = G_DATE_SUNDAY;
break;
case G_DATE_TUESDAY:
prev = G_DATE_MONDAY;
break;
case G_DATE_WEDNESDAY:
prev = G_DATE_TUESDAY;
break;
case G_DATE_THURSDAY:
prev = G_DATE_WEDNESDAY;
break;
case G_DATE_FRIDAY:
prev = G_DATE_THURSDAY;
break;
case G_DATE_SATURDAY:
prev = G_DATE_FRIDAY;
break;
case G_DATE_SUNDAY:
prev = G_DATE_SATURDAY;
break;
default:
prev = G_DATE_BAD_WEEKDAY;
break;
}
return prev;
}
/* Evolution Locks for crash recovery */
static const gchar *
get_lock_filename (void)
......
......@@ -139,6 +139,8 @@ const gchar * e_get_month_name (GDateMonth month,
gboolean abbreviated);
const gchar * e_get_weekday_name (GDateWeekday weekday,
gboolean abbreviated);
GDateWeekday e_get_next_weekday (GDateWeekday weekday);
GDateWeekday e_get_prev_weekday (GDateWeekday weekday);
gboolean e_file_lock_create (void);
void e_file_lock_destroy (void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment