aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/itip-formatter/itip-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/itip-formatter/itip-view.c')
-rw-r--r--plugins/itip-formatter/itip-view.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/itip-formatter/itip-view.c b/plugins/itip-formatter/itip-view.c
index 64cb01f1ef..3d644eca93 100644
--- a/plugins/itip-formatter/itip-view.c
+++ b/plugins/itip-formatter/itip-view.c
@@ -150,7 +150,8 @@ format_date_and_time_x (struct tm *date_tm,
/* Calculate a normalized "tomorrow" */
tomorrow_tm = *current_tm;
- if (tomorrow_tm.tm_mday == time_days_in_month (date_tm->tm_year + 1900, date_tm->tm_mon)) {
+ /* Don't need this if date is in the past. Also, year assumption won't fail. */
+ if (date_tm->tm_year >= current_tm->tm_year && tomorrow_tm.tm_mday == time_days_in_month (date_tm->tm_year + 1900, date_tm->tm_mon)) {
tomorrow_tm.tm_mday = 1;
if (tomorrow_tm.tm_mon == 11) {
tomorrow_tm.tm_mon = 1;
@@ -164,7 +165,8 @@ format_date_and_time_x (struct tm *date_tm,
/* Calculate a normalized "next seven days" */
week_tm = *current_tm;
- if (week_tm.tm_mday + 6 > time_days_in_month (date_tm->tm_year + 1900, date_tm->tm_mon)) {
+ /* Don't need this if date is in the past. Also, year assumption won't fail. */
+ if (date_tm->tm_year >= current_tm->tm_year && week_tm.tm_mday + 6 > time_days_in_month (date_tm->tm_year + 1900, date_tm->tm_mon)) {
week_tm.tm_mday = (week_tm.tm_mday + 6) % time_days_in_month (date_tm->tm_year + 1900, date_tm->tm_mon);
if (week_tm.tm_mon == 11) {
week_tm.tm_mon = 1;