[asterisk-commits] twilson: branch twilson/calendaring r161534 - /team/twilson/calendaring/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Dec 6 01:49:44 CST 2008


Author: twilson
Date: Sat Dec  6 01:49:41 2008
New Revision: 161534

URL: http://svn.digium.com/view/asterisk?view=rev&rev=161534
Log:
Add start, end, and alarm to "calendar show calendar" CLI command

Modified:
    team/twilson/calendaring/main/calendar.c

Modified: team/twilson/calendaring/main/calendar.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/main/calendar.c?view=diff&rev=161534&r1=161533&r2=161534
==============================================================================
--- team/twilson/calendaring/main/calendar.c (original)
+++ team/twilson/calendaring/main/calendar.c Sat Dec  6 01:49:41 2008
@@ -1139,6 +1139,23 @@
 #undef FORMAT
 }
 
+static char *epoch_to_string(char *buf, size_t buflen, time_t epoch)
+{
+	struct ast_tm tm;
+	struct timeval tv = {
+		.tv_sec = epoch,
+	};
+
+	if (!epoch) {
+		*buf = '\0';
+		return buf;
+	}
+	ast_localtime(&tv, &tm, NULL);
+	ast_strftime(buf, buflen, "%F %r", &tm);
+
+	return buf;
+}
+
 static char *handle_show_calendar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 #define FORMAT "%-17.17s : %-20.20s\n"
@@ -1195,12 +1212,18 @@
 
 	i = ao2_iterator_init(cal->events, 0);
 	while ((event = ao2_iterator_next(&i))) {
+		char buf[100];
+
 		ast_cli(a->fd, FORMAT2, "Summary", event->summary);
 		ast_cli(a->fd, FORMAT2, "Description", event->description);
 		ast_cli(a->fd, FORMAT2, "Organizer", event->organizer);
 		ast_cli(a->fd, FORMAT2, "Location", event->location);
 		ast_cli(a->fd, FORMAT2, "UID", event->uid);
+		ast_cli(a->fd, FORMAT2, "Start", epoch_to_string(buf, sizeof(buf), event->start));
+		ast_cli(a->fd, FORMAT2, "End", epoch_to_string(buf, sizeof(buf), event->end));
+		ast_cli(a->fd, FORMAT2, "Alarm", epoch_to_string(buf, sizeof(buf), event->alarm));
 		ast_cli(a->fd, "\n");
+
 		event = ast_calendar_unref_event(event);
 	}
 	cal = unref_calendar(cal);




More information about the asterisk-commits mailing list