summaryrefslogtreecommitdiff
path: root/libmu_sieve
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-12-08 19:49:49 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-12-08 19:52:40 +0200
commit76cc330864a9680365123c86f8d5a394f952dcc5 (patch)
tree99a410b036db6e2caa7821ac5f6ebf40f4d29c6c /libmu_sieve
parent912224f8b9fd7638fd48b86670fffca693c2bf9f (diff)
downloadmailutils-76cc330864a9680365123c86f8d5a394f952dcc5.tar.gz
mailutils-76cc330864a9680365123c86f8d5a394f952dcc5.tar.bz2
New function mu_datetime_tz_local.
The function initializes mu_timezone structure to the local timezone. * include/mailutils/datetime.h (mu_utc_offset): Change return type. (mu_datetime_tz_local): New proto. * libmailutils/datetime/tzlocal.c: New file. * libmailutils/datetime/Makefile.am: Add new file. * libmailutils/datetime/scantime.c (mu_scan_datetime): Use mu_datetime_tz_local to initialize local TZ. * mh/mh_format.c (_parse_date): Likewise. * libmailutils/datetime/utcoff.c (mu_utc_offset): Returns int. * libmu_sieve/actions.c (mime_create_ds): Use mu_c_streamftime to format time directly to stream.
Diffstat (limited to 'libmu_sieve')
-rw-r--r--libmu_sieve/actions.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index a475d4794..ebc301560 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -185,12 +185,11 @@ mime_create_ds (mu_mime_t mime, mu_message_t orig)
mu_header_t hdr;
mu_body_t body;
char *email;
- char datestr[80];
- time_t t = time (NULL);
struct tm tm, *tmp;
struct mu_timezone tz;
mu_envelope_t env;
const char *p;
+ time_t t = time (NULL);
mu_message_create (&newmsg, NULL);
mu_message_get_header (newmsg, &hdr);
@@ -202,15 +201,17 @@ mime_create_ds (mu_mime_t mime, mu_message_t orig)
mu_message_get_envelope (orig, &env);
if (mu_envelope_sget_date (env, &p) == 0
&& mu_scan_datetime (p, MU_DATETIME_FROM, &tm, &tz, NULL) == 0)
- t = mu_datetime_to_utc (&tm, &tz);
+ {
+ tmp = &tm;
+ }
else
- /* Use local time instead */
- t = time (NULL);
- tmp = localtime (&t);
+ {
+ tmp = localtime (&t);
+ mu_datetime_tz_local (&tz);
+ }
- /* FIXME: timezone info is lost */
- mu_strftime (datestr, sizeof datestr, "%a, %b %d %H:%M:%S %Y %Z", tmp);
- mu_stream_printf (stream, "Arrival-Date: %s\n", datestr);
+ mu_c_streamftime (stream, "Arrival-Date: %a, %b %d %H:%M:%S %Y %Z%n",
+ tmp, &tz);
email = mu_get_user_email (NULL);
mu_stream_printf (stream, "Final-Recipient: RFC822; %s\n",
@@ -220,10 +221,10 @@ mime_create_ds (mu_mime_t mime, mu_message_t orig)
mu_stream_printf (stream,
"Disposition: automatic-action/MDN-sent-automatically;deleted\n");
- t = time (NULL);
tmp = localtime (&t);
- mu_strftime (datestr, sizeof datestr, "%a, %b %d %H:%M:%S %Y %Z", tmp);
- mu_stream_printf (stream, "Last-Attempt-Date: %s\n", datestr);
+ mu_datetime_tz_local (&tz);
+ mu_c_streamftime (stream, "Last-Attempt-Date: %a, %b %d %H:%M:%S %Y %Z%n",
+ tmp, &tz);
mu_stream_close (stream);
mu_stream_destroy (&stream);

Return to:

Send suggestions and report system problems to the System administrator.