[balsa] Display time stamps of date-only iCalendar events
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Display time stamps of date-only iCalendar events
- Date: Tue, 1 May 2018 20:01:40 +0000 (UTC)
commit b7021b778b5837533cdc69bceda3d018f97df1f6
Author: Albrecht Dreß <albrecht dress arcor de>
Date: Tue May 1 15:59:48 2018 -0400
Display time stamps of date-only iCalendar events
Display time stamps of date-only RFC 5545 iCalendar events
Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>
ChangeLog | 14 ++++++++++++++
libbalsa/rfc2445.c | 26 ++++++++++++++++++++------
libbalsa/rfc2445.h | 4 +++-
src/balsa-mime-widget-vcalendar.c | 9 +++++----
src/balsa-print-object-text.c | 9 +++++----
5 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0344c62..11da7d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2018-05-01 Albrecht Dreß <albrecht dress arcor de>
+
+ Display time stamps of date-only RFC 5545 iCalendar events
+
+I noticed that “VALUE=DATE” time stamps (date only, without time) in RFC 5545 iCalendar parts (MIME type
text/calendar) are not displayed.
+
+The attached trivial patch add parsing, displaying and printing such values As to simplify life, the
date-only values are printed using the “%x” conversion specification, instead of extracting the date part
from balsa_app.date_string.
+
+ * libbalsa/rfc2445.c (libbalsa_vcal_new_from_body),
+ (date_time_2445_to_time_t):
+ * libbalsa/rfc2445.h:
+ * src/balsa-mime-widget-vcalendar.c (balsa_vevent_widget):
+ * src/balsa-print-object-text.c (balsa_print_object_text_calendar):
+
2018-04-11 Peter Bloomfield <pbloomfield bellsouth net>
Fix the "scroll on click" issue
diff --git a/libbalsa/rfc2445.c b/libbalsa/rfc2445.c
index 603cb7a..0a15688 100644
--- a/libbalsa/rfc2445.c
+++ b/libbalsa/rfc2445.c
@@ -66,7 +66,7 @@ static LibBalsaAddress *cal_address_2445_to_lbaddress(const gchar * uri,
is_organizer);
/* conversion helpers */
-static time_t date_time_2445_to_time_t(const gchar * date_time);
+static time_t date_time_2445_to_time_t(const gchar *date_time, const gchar *modifier, gboolean *date_only);
static gchar *time_t_to_date_time_2445(time_t ttime);
static gchar *text_2445_unescape(const gchar * text);
static gchar *text_2445_escape(const gchar * text);
@@ -377,11 +377,11 @@ libbalsa_vcal_new_from_body(LibBalsaMessageBody * body)
in_embedded = TRUE;
else if (!in_embedded) {
if (!g_ascii_strcasecmp(entry[0], "DTSTART"))
- event->start = date_time_2445_to_time_t(value);
+ event->start = date_time_2445_to_time_t(value, entry[1], &event->start_date_only);
else if (!g_ascii_strcasecmp(entry[0], "DTEND"))
- event->end = date_time_2445_to_time_t(value);
+ event->end = date_time_2445_to_time_t(value, entry[1], &event->end_date_only);
else if (!g_ascii_strcasecmp(entry[0], "DTSTAMP"))
- event->stamp = date_time_2445_to_time_t(value);
+ event->stamp = date_time_2445_to_time_t(value, entry[1], NULL);
else if (!g_ascii_strcasecmp(entry[0], "UID"))
STR_REPL_2445_TXT(event->uid, value);
else if (!g_ascii_strcasecmp(entry[0], "SUMMARY"))
@@ -537,10 +537,10 @@ libbalsa_vevent_reply(const LibBalsaVEvent * event, const gchar * sender,
/* convert a rfc 2445 time string into a time_t value */
// FIXME - what about entries containing a TZID?
static time_t
-date_time_2445_to_time_t(const gchar *date_time)
+date_time_2445_to_time_t(const gchar *date_time, const gchar *modifier, gboolean *date_only)
{
gint len;
- time_t the_time = (time_t) (-1);;
+ time_t the_time = (time_t) (-1);
g_return_val_if_fail(date_time != NULL, (time_t) (-1));
len = strlen(date_time);
@@ -553,7 +553,21 @@ date_time_2445_to_time_t(const gchar *date_time)
/* the rfc2445 date-time is a special case of an iso8901 date/time value... */
if (g_time_val_from_iso8601(date_time, &timeval)) {
the_time = timeval.tv_sec;
+ if (date_only != NULL) {
+ *date_only = FALSE;
+ }
}
+ } else if ((modifier!= NULL) && (g_ascii_strcasecmp(modifier, "VALUE=DATE") == 0) && (len == 8)) {
+ struct tm tm;
+
+ /* date only (yyyymmdd) */
+ memset(&tm, 0, sizeof(tm));
+ if (strptime(date_time, "%Y%m%d", &tm) != NULL) {
+ the_time = mktime(&tm);
+ if (date_only != NULL) {
+ *date_only = TRUE;
+ }
+ }
}
return the_time;
diff --git a/libbalsa/rfc2445.h b/libbalsa/rfc2445.h
index 710c66b..dca5d6c 100644
--- a/libbalsa/rfc2445.h
+++ b/libbalsa/rfc2445.h
@@ -1,7 +1,7 @@
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
/*
* VCalendar (RFC 2445) stuff
- * Copyright (C) 2009 Albrecht Dre� <albrecht dress arcor de>
+ * Copyright (C) 2009 Albrecht Dreß <albrecht dress arcor de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -95,7 +95,9 @@ struct _LibBalsaVEvent {
GList *attendee;
time_t stamp;
time_t start;
+ gboolean start_date_only;
time_t end;
+ gboolean end_date_only;
gchar *uid;
gchar *summary;
gchar *location;
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index 34e70cb..6f14747 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -118,11 +118,12 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
} \
} while (0)
-#define GRID_ATTACH_DATE(g,date,label) \
+#define GRID_ATTACH_DATE(g,date,date_only,label) \
do { \
if (date != (time_t) -1) { \
gchar * _dstr = \
- libbalsa_date_to_utf8(date, balsa_app.date_string); \
+ libbalsa_date_to_utf8(date, \
+ date_only ? "%x" : balsa_app.date_string); \
GRID_ATTACH(g, _dstr, label); \
g_free(_dstr); \
} \
@@ -170,8 +171,8 @@ balsa_vevent_widget(LibBalsaVEvent * event, gboolean may_reply,
gtk_grid_set_column_spacing(grid, 12);
GRID_ATTACH(grid, event->summary, _("Summary:"));
GRID_ATTACH_ADDRESS(grid, event->organizer, _("Organizer:"));
- GRID_ATTACH_DATE(grid, event->start, _("Start:"));
- GRID_ATTACH_DATE(grid, event->end, _("End:"));
+ GRID_ATTACH_DATE(grid, event->start, event->start_date_only, _("Start:"));
+ GRID_ATTACH_DATE(grid, event->end, event->end_date_only, _("End:"));
GRID_ATTACH(grid, event->location, _("Location:"));
if (event->attendee) {
GList *att;
diff --git a/src/balsa-print-object-text.c b/src/balsa-print-object-text.c
index 77e0091..397bc5d 100644
--- a/src/balsa-print-object-text.c
+++ b/src/balsa-print-object-text.c
@@ -555,11 +555,12 @@ balsa_print_object_text_vcard(GList * list,
} \
} while(0)
-#define ADD_VCAL_DATE(buf, labwidth, layout, date, descr) \
+#define ADD_VCAL_DATE(buf, labwidth, layout, date, date_only, descr) \
do { \
if (date != (time_t) -1) { \
gchar * _dstr = \
- libbalsa_date_to_utf8(date, balsa_app.date_string); \
+ libbalsa_date_to_utf8(date, \
+ date_only ? "%x" : balsa_app.date_string); \
ADD_VCAL_FIELD(buf, labwidth, layout, _dstr, descr); \
g_free(_dstr); \
} \
@@ -650,9 +651,9 @@ balsa_print_object_text_calendar(GList * list,
ADD_VCAL_ADDRESS(desc_buf, pod->p_label_width, test_layout,
event->organizer, _("Organizer"));
ADD_VCAL_DATE(desc_buf, pod->p_label_width, test_layout,
- event->start, _("Start"));
+ event->start, event->start_date_only, _("Start"));
ADD_VCAL_DATE(desc_buf, pod->p_label_width, test_layout,
- event->end, _("End"));
+ event->end, event->end_date_only, _("End"));
ADD_VCAL_FIELD(desc_buf, pod->p_label_width, test_layout,
event->location, _("Location"));
if (event->attendee) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]