2 * Evolution calendar - Miscellaneous utility functions
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * Federico Mena-Quintero <federico@ximian.com>
20 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
24 #include "evolution-config.h"
28 #include <glib/gi18n.h>
36 * Returns whether a string is NULL, the empty string, or completely made up of
37 * whitespace characters.
39 * Return value: TRUE if the string is empty, FALSE otherwise.
42 string_is_empty (const gchar
*value
)
52 if (!isspace ((guchar
) *p
)) {
64 get_position_in_array (GPtrArray
*objects
,
69 for (i
= 0; i
< objects
->len
; i
++) {
70 if (g_ptr_array_index (objects
, i
) == item
)
78 calculate_time (time_t start
,
81 time_t difference
= end
- start
;
89 if (difference
>= 24 * 3600) {
92 days
= difference
/ (24 * 3600);
93 difference
%= (24 * 3600);
95 times
[i
++] = g_strdup_printf (ngettext ("%d day", "%d days", days
), days
);
97 if (difference
>= 3600) {
98 hours
= difference
/ 3600;
101 times
[i
++] = g_strdup_printf (ngettext ("%d hour", "%d hours", hours
), hours
);
103 if (difference
>= 60) {
104 minutes
= difference
/ 60;
107 times
[i
++] = g_strdup_printf (ngettext ("%d minute", "%d minutes", minutes
), minutes
);
109 if (i
== 0 || difference
!= 0) {
110 /* TRANSLATORS: here, "second" is the time division (like "minute"), not the ordinal number (like "third") */
111 times
[i
++] = g_strdup_printf (ngettext ("%d second", "%d seconds", difference
), (gint
) difference
);
115 joined
= g_strjoinv (" ", times
);
116 str
= g_strconcat ("(", joined
, ")", NULL
);