aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/util.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2005-11-24 23:28:11 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2005-11-24 23:28:11 +0800
commit25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b (patch)
tree47828615efb7cefb23ca816cda38a35423cc5697 /calendar/gui/alarm-notify/util.c
parent9c0eef3dd90ab8e7db04901b3079e097cdd7f400 (diff)
downloadgsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar.gz
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar.bz2
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar.lz
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar.xz
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.tar.zst
gsoc2013-evolution-25d053c312af01acc9cb2ba1672f3f7ed4ea5e8b.zip
Changes for alarm notification bubble
svn path=/trunk/; revision=30661
Diffstat (limited to 'calendar/gui/alarm-notify/util.c')
-rw-r--r--calendar/gui/alarm-notify/util.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/calendar/gui/alarm-notify/util.c b/calendar/gui/alarm-notify/util.c
index ac24bbb56d..900d20e67d 100644
--- a/calendar/gui/alarm-notify/util.c
+++ b/calendar/gui/alarm-notify/util.c
@@ -47,3 +47,52 @@ timet_to_str_with_zone (time_t t, icaltimezone *zone)
FALSE, FALSE, buf, sizeof (buf));
return g_strdup (buf);
}
+
+char *
+calculate_time (time_t start, time_t end)
+{
+ time_t difference = end - start;
+ char *str;
+
+ if (difference < 60) {/* Can't be zero */
+ str = g_strdup_printf (_("(%d seconds)"), difference);
+ } else if (difference > 60 && difference < 3600) { /* It will be x minutes y seconds*/
+ int minutes, seconds;
+ minutes = difference / 60;
+ seconds = difference % 60;
+ if (seconds)
+ str = g_strdup_printf (_("(%d %s %d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes), seconds, ngettext(_("second"), _("seconds"), seconds));
+ else
+ str = g_strdup_printf (_("(%d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes));
+ } else {
+ guint hours, minutes, seconds;
+ char *s_hours = NULL, *s_minutes = NULL, *s_seconds = NULL;
+
+ hours = difference / 3600;
+ minutes = (difference % 3600)/60;
+ seconds = difference % 60;
+
+
+ if (seconds)
+ s_seconds = g_strdup_printf (ngettext(_(" %u second"), _(" %u seconds"), seconds), seconds);
+ if (minutes)
+ s_minutes = g_strdup_printf (ngettext(_(" %u minute"), _(" %u minutes"), minutes), minutes);
+ if (hours)
+ s_hours = g_strdup_printf (ngettext(_("%u hour"),_("%u hours"), hours), hours);
+
+ if (s_minutes && s_seconds)
+ str = g_strconcat ("(", s_hours, s_minutes, s_seconds, ")", NULL);
+ else if (s_minutes)
+ str = g_strconcat ("(", s_hours, s_minutes, ")", NULL);
+ else if (s_seconds)
+ str = g_strconcat ("(", s_hours, s_seconds, ")", NULL);
+ else
+ str = g_strconcat ("(", s_hours, ")", NULL);
+
+ g_free (s_hours);
+ g_free (s_minutes);
+ g_free (s_seconds);
+ }
+
+ return g_strchug(str);
+}