diff options
author | JP Rosevear <jpr@novell.com> | 2005-01-28 12:30:30 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2005-01-28 12:30:30 +0800 |
commit | 7d76d9858a79a758acbadff96417018d0b9a13d8 (patch) | |
tree | 6bf6e69f1be31f1ae1701b03c2ddd5278f957146 /plugins | |
parent | 4fca3e656fa19a29f0657a0c20152bc223e81583 (diff) | |
download | gsoc2013-evolution-7d76d9858a79a758acbadff96417018d0b9a13d8.tar.gz gsoc2013-evolution-7d76d9858a79a758acbadff96417018d0b9a13d8.tar.zst gsoc2013-evolution-7d76d9858a79a758acbadff96417018d0b9a13d8.zip |
make tomorrow and this week strings work properly
2005-01-27 JP Rosevear <jpr@novell.com>
* itip-view.c (format_date_and_time_x): make tomorrow and this
week strings work properly
svn path=/trunk/; revision=28591
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/itip-formatter/ChangeLog | 5 | ||||
-rw-r--r-- | plugins/itip-formatter/itip-view.c | 48 |
2 files changed, 50 insertions, 3 deletions
diff --git a/plugins/itip-formatter/ChangeLog b/plugins/itip-formatter/ChangeLog index 9c7dc58d4e..49d14ce352 100644 --- a/plugins/itip-formatter/ChangeLog +++ b/plugins/itip-formatter/ChangeLog @@ -1,5 +1,10 @@ 2005-01-27 JP Rosevear <jpr@novell.com> + * itip-view.c (format_date_and_time_x): make tomorrow and this + week strings work properly + +2005-01-27 JP Rosevear <jpr@novell.com> + * itip-formatter.c (find_cal_opened_cb): remove debug test 442005-01-27 JP Rosevear <jpr@novell.com> diff --git a/plugins/itip-formatter/itip-view.c b/plugins/itip-formatter/itip-view.c index e531a4201f..afed28b4ec 100644 --- a/plugins/itip-formatter/itip-view.c +++ b/plugins/itip-formatter/itip-view.c @@ -135,6 +135,35 @@ format_date_and_time_x (struct tm *date_tm, int buffer_size) { char *format; + struct tm tomorrow_tm, week_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)) { + tomorrow_tm.tm_mday = 1; + if (tomorrow_tm.tm_mon == 11) { + tomorrow_tm.tm_mon = 1; + tomorrow_tm.tm_year++; + } else { + tomorrow_tm.tm_mon++; + } + } else { + tomorrow_tm.tm_mday++; + } + + /* 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)) { + 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; + week_tm.tm_year++; + } else { + week_tm.tm_mon++; + } + } else { + week_tm.tm_mday += 6; + } /* Today */ if (date_tm->tm_mday == current_tm->tm_mday && @@ -165,7 +194,9 @@ format_date_and_time_x (struct tm *date_tm, } /* Tomorrow */ - } else if (date_tm->tm_year == current_tm->tm_year) { + } else if (date_tm->tm_mday == tomorrow_tm.tm_mday && + date_tm->tm_mon == tomorrow_tm.tm_mon && + date_tm->tm_year == tomorrow_tm.tm_year) { if (!show_midnight && date_tm->tm_hour == 0 && date_tm->tm_min == 0 && date_tm->tm_sec == 0) { /* strftime format of a weekday and a date. */ @@ -190,8 +221,19 @@ format_date_and_time_x (struct tm *date_tm, format = _("Tomorrow %l:%M:%S %p"); } - /* Within 7 days */ - } else if (date_tm->tm_year == current_tm->tm_year) { + /* Within 6 days */ + } else if ((date_tm->tm_year >= current_tm->tm_year && + date_tm->tm_mon >= current_tm->tm_mon && + date_tm->tm_mday >= current_tm->tm_mday) && + + (date_tm->tm_year < week_tm.tm_year || + + (date_tm->tm_year == week_tm.tm_year && + date_tm->tm_mon < week_tm.tm_mon) || + + (date_tm->tm_year == week_tm.tm_year && + date_tm->tm_mon == week_tm.tm_mon && + date_tm->tm_mday < week_tm.tm_mday))) { if (!show_midnight && date_tm->tm_hour == 0 && date_tm->tm_min == 0 && date_tm->tm_sec == 0) { /* strftime format of a weekday. */ |