[california/wip/732930-explain] Simple start
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/732930-explain] Simple start
- Date: Wed, 3 Sep 2014 01:21:58 +0000 (UTC)
commit 6a8c970d68da6aa9b8f39a310e29b247565710d9
Author: Jim Nelson <jim yorba org>
Date: Tue Sep 2 18:21:38 2014 -0700
Simple start
src/component/component-recurrence-rule.vala | 48 ++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/component/component-recurrence-rule.vala b/src/component/component-recurrence-rule.vala
index 9bd45e3..ee0b293 100644
--- a/src/component/component-recurrence-rule.vala
+++ b/src/component/component-recurrence-rule.vala
@@ -577,6 +577,54 @@ public class RecurrenceRule : BaseObject {
ical_by_ar[index] = (short) iCal.RECURRENCE_ARRAY_MAX;
}
+ /**
+ * Returns a natural-language string explaining the { link RecurrenceRule} for the user.
+ *
+ * Returns null if the RRULE is beyond the comprehension of this parser.
+ */
+ public string? explain() {
+ string unit;
+ switch (freq) {
+ case iCal.icalrecurrencetype_frequency.DAILY_RECURRENCE:
+ unit = ngettext("day", "%d days", interval);
+ break;
+
+ case iCal.icalrecurrencetype_frequency.WEEKLY_RECURRENCE:
+ unit = ngettext("week", "%d weeks", interval);
+ break;
+
+ case iCal.icalrecurrencetype_frequency.MONTHLY_RECURRENCE:
+ unit = ngettext("month", "%d months", interval);
+ break;
+
+ case iCal.icalrecurrencetype_frequency.YEARLY_RECURRENCE:
+ unit = ngettext("year", "%d years", interval);
+ break;
+
+ default:
+ return null;
+ }
+
+ if (count > 0) {
+ return _("Repeats every %s for %s").printf(unit.printf(interval), unit.printf(count));
+ }
+
+ if (until_date != null) {
+ return _("Repeats every %s until %s").printf(unit.printf(interval),
+ until_date.to_pretty_string(Calendar.Date.PrettyFlag.INCLUDE_YEAR)
+ );
+ }
+
+ if (until_exact_time != null) {
+ return _("Repeats every %s until %s, %s").printf(unit.printf(interval),
+ until_exact_time.to_pretty_date_string(Calendar.Date.PrettyFlag.INCLUDE_YEAR),
+ until_exact_time.to_pretty_time_string(Calendar.WallTime.PrettyFlag.NONE)
+ );
+ }
+
+ return _("Repeats every %s").printf(unit.printf(interval));
+ }
+
public override string to_string() {
return "RRULE %s".printf(freq.to_string());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]