diff options
author | Eduardo Chappa <chappa@washington.edu> | 2021-12-24 14:36:53 -0700 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2021-12-24 14:36:53 -0700 |
commit | 1e6c61f80a9e2c5a456477ea42732f63d3b3118f (patch) | |
tree | 2be058896c4fdc25b10fefbb7f0f40ae08cfcace /pith | |
parent | 21cee6130dc8fcd82b50c2cee347eb5c37ff457b (diff) | |
download | alpine-1e6c61f80a9e2c5a456477ea42732f63d3b3118f.tar.xz |
* Correct release notes. Based on report by Dennis Davis.
* Correct spellings in imap/Makefile. Contributed by Gerald Pfeifer.
* Change comparison of ps_global->inbox_name from strcmp to strucmp in
do_broach_folder.
* When an invitation does not have a timezone in the date of the event,
but the date is in GMT, adjust the date to local time.
Diffstat (limited to 'pith')
-rw-r--r-- | pith/ical.c | 38 | ||||
-rw-r--r-- | pith/mailcmd.c | 2 | ||||
-rw-r--r-- | pith/pine.hlp | 8 | ||||
-rw-r--r-- | pith/string.c | 73 | ||||
-rw-r--r-- | pith/string.h | 1 |
5 files changed, 90 insertions, 32 deletions
diff --git a/pith/ical.c b/pith/ical.c index 1798d3fb..d821e9b0 100644 --- a/pith/ical.c +++ b/pith/ical.c @@ -1,6 +1,7 @@ #include "../pith/headers.h" #include "../pith/mailpart.h" #include "../pith/store.h" +#include "../pith/string.h" #include "../pith/ical.h" typedef struct ical_iana_comp_s { @@ -2180,9 +2181,15 @@ ical_vevent_summary(VCALENDAR_S *vcal) VEVENT_S *vevent; GEN_ICLINE_S *gicl; ICLINE_S *icl; + static int offset = 1000000; /* impossible value */ + static int dst; + time_t ourtime; if(vcal == NULL) return NULL; + if(offset == 1000000) + offset = timezone_offset_to_gmt(&dst); + method = vcal->method; vevent = (VEVENT_S *) vcal->comp[VEvent]; @@ -2255,6 +2262,15 @@ ical_vevent_summary(VCALENDAR_S *vcal) tzid = ical_get_tzid(icl->param); if(icd >= 0){ ic_date.tm_wday = ical_day_of_week(ic_date); + if(ic_date.tm_isdst == 1){ /* GMT time */ + ic_date.tm_isdst = dst; + ourtime = mktime(&ic_date); + if(ourtime != (time_t) -1){ + ourtime += offset; + ic_date = *localtime(&ourtime); + } + } + ic_date.tm_isdst = dst; switch(icd){ case 0: /* DATE-TIME */ ical_date_time(tmp, sizeof(tmp), &ic_date); @@ -2343,7 +2359,16 @@ ical_vevent_summary(VCALENDAR_S *vcal) tzid = ical_get_tzid(icl->param); if(icd >= 0){ ic_date.tm_wday = ical_day_of_week(ic_date); - switch(icd){ + if(ic_date.tm_isdst == 1){ /* GMT time */ + ic_date.tm_isdst = dst; + ourtime = mktime(&ic_date); + if(ourtime != (time_t) -1){ + ourtime += offset; + ic_date = *localtime(&ourtime); + } + } + ic_date.tm_isdst = dst; + switch(icd){ case 0: /* DATE-TIME */ ical_date_time(tmp, sizeof(tmp), &ic_date); break; @@ -2355,7 +2380,7 @@ ical_vevent_summary(VCALENDAR_S *vcal) break; default: alpine_panic("Unhandled ical date format"); break; - } + } } else{ strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); @@ -2391,6 +2416,15 @@ ical_vevent_summary(VCALENDAR_S *vcal) tzid = ical_get_tzid(icl->param); if(icd >= 0){ ic_date.tm_wday = ical_day_of_week(ic_date); + if(ic_date.tm_isdst == 1){ /* GMT time */ + ic_date.tm_isdst = dst; + ourtime = mktime(&ic_date); + if(ourtime != (time_t) -1){ + ourtime += offset; + ic_date = *localtime(&ourtime); + } + } + ic_date.tm_isdst = dst; switch(icd){ case 0: /* DATE-TIME */ ical_date_time(tmp, sizeof(tmp), &ic_date); diff --git a/pith/mailcmd.c b/pith/mailcmd.c index c53afeb4..4ddd26f6 100644 --- a/pith/mailcmd.c +++ b/pith/mailcmd.c @@ -831,7 +831,7 @@ do_broach_folder(char *newfolder, CONTEXT_S *new_context, MAILSTREAM **streamp, dprint((8, "Old folder: \"%s\"\n", old_folder == NULL ? "" : old_folder)); if(old_folder != NULL){ - if(strcmp(old_folder, ps_global->inbox_name) == 0){ + if(strucmp(old_folder, ps_global->inbox_name) == 0){ ps_global->mail_stream = sp_inbox_stream(); ps_global->msgmap = sp_msgmap(ps_global->mail_stream); diff --git a/pith/pine.hlp b/pith/pine.hlp index 6c41112a..b78e089a 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 632 2021-12-04 17:11:12 +Alpine Commit 633 2021-12-24 14:36:46 ============= h_news ================= <HTML> <HEAD> @@ -184,7 +184,8 @@ Since the Privacy Policy could be amended to take into consideration new additions to Alpine, please check it periodically. <P> Changes since the release of version 2.25 include: -<!-- Changes since the release of version <!--#echo var="ALPINE_VERSION"--> include: --> +<!-- Changes since the release of version <!--#echo var="ALPINE_VERSION"--> +<!-- include: --> <P> New features include: <UL> @@ -234,6 +235,9 @@ new additions to Alpine, please check it periodically. <LI> If new mail has arrived when a user is closing a mailbox, Alpine will also announce how many new messages have arrived. Suggested by Chime Hart. + +<LI> When an invitation does not have a timezone in the date of the event, + but the date is in GMT, adjust the date to local time. </UL> <P> diff --git a/pith/string.c b/pith/string.c index d7f5c256..878ff5b4 100644 --- a/pith/string.c +++ b/pith/string.c @@ -1059,14 +1059,27 @@ static struct { {"CDT", 3, -5, 0}, /* Central Daylight */ {"EST", 3, -5, 0}, /* Eastern Standard */ {"EDT", 3, -4, 0}, /* Eastern Daylight */ - {"JST", 3, 9, 0}, /* Japan Standard */ {"GMT", 3, 0, 0}, /* Universal Time */ {"UT", 2, 0, 0}, /* Universal Time */ -#ifdef IST_MEANS_ISREAL + {"WET", 3, 0, 0}, /* Western Europe Standard */ + {"WEST", 4, 1, 0}, /* Western Europe Daylight */ + {"CET", 3, 1, 0}, /* Central Europe Standard */ + {"CEST", 4, 2, 0}, /* Central Europe Daylight */ + {"EET", 3, 2, 0}, /* Eastern Europe Standard */ + {"EEST", 4, 3, 0}, /* Eastern Europe Daylight */ + {"FET", 3, 3, 0}, /* Further Eastern Europe Standard */ + {"MSK", 3, 3, 0}, /* Moscow Standard Time */ + {"BST", 3, 1, 0}, /* Brittish Summer Time */ + {"JST", 3, 9, 0}, /* Japan Standard */ +#ifdef IST_MEANS_ISRAEL {"IST", 3, 2, 0}, /* Israel Standard */ #else #ifdef IST_MEANS_INDIA {"IST", 3, 5, 30}, /* India Standard */ +#else +#ifdef IST_MEANS_IRISH + {"IST", 3, 1, 0}, /* Irish Standard */ +#endif #endif #endif {NULL, 0, 0}, @@ -1324,6 +1337,35 @@ convert_date_to_local(char *date) } +int +timezone_offset_to_gmt(int *dst) +{ + int julian, offset; + struct tm *tm; + time_t now; + + offset = 0; + /* find difference between gmtime and localtime, from c-client do_date */ + now = time((time_t *) 0); + if(now != (time_t) -1){ + tm = gmtime(&now); + if(tm != NULL){ + offset = tm->tm_hour * 60 + tm->tm_min; /* minutes */ + julian = tm->tm_yday; + + tm = localtime(&now); + *dst = tm->tm_isdst; /* for converting back to our time */ + + offset = tm->tm_hour * 60 + tm->tm_min - offset; + if((julian = tm->tm_yday - julian) != 0) + offset += ((julian < 0) == (abs(julian) == 1)) ? -24*60 : 24*60; + + offset *= 60; /* change to seconds */ + } + } + return offset; +} + time_t date_to_local_time_t(char *date) { @@ -1333,31 +1375,8 @@ date_to_local_time_t(char *date) static int zone = 1000000; /* initialize timezone offset */ static int dst; - if(zone == 1000000){ - int julian; - struct tm *tm; - time_t now; - - zone = 0; - /* find difference between gmtime and localtime, from c-client do_date */ - now = time((time_t *) 0); - if(now != (time_t) -1){ - tm = gmtime(&now); - if(tm != NULL){ - zone = tm->tm_hour * 60 + tm->tm_min; /* minutes */ - julian = tm->tm_yday; - - tm = localtime(&now); - dst = tm->tm_isdst; /* for converting back to our time */ - - zone = tm->tm_hour * 60 + tm->tm_min - zone; - if((julian = tm->tm_yday - julian) != 0) - zone += ((julian < 0) == (abs(julian) == 1)) ? -24*60 : 24*60; - - zone *= 60; /* change to seconds */ - } - } - } + if(zone == 1000000) + zone = timezone_offset_to_gmt(&dst); parse_date(date, &d); diff --git a/pith/string.h b/pith/string.h index 36440ea6..9aeb3529 100644 --- a/pith/string.h +++ b/pith/string.h @@ -152,5 +152,6 @@ int read_octal(char **); time_t date_to_local_time_t(char *); void convert_decimal_to_roman (char *, size_t, long, char); void convert_decimal_to_alpha (char *, size_t, long, char); +int timezone_offset_to_gmt(int *); #endif /* PITH_STRING_INCLUDED */ |