summaryrefslogtreecommitdiff
path: root/mh
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-04 12:41:29 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-07-04 12:41:29 +0300
commit3fc6fc8ae9fe5980abf25e109c96934cb1fdb1eb (patch)
treea8e86fd4842381fe7c470b6ce0d8806bc7c07d85 /mh
parent55ce659fd9a9aa49de31d33f7937fb5966fb2e1d (diff)
downloadmailutils-3fc6fc8ae9fe5980abf25e109c96934cb1fdb1eb.tar.gz
mailutils-3fc6fc8ae9fe5980abf25e109c96934cb1fdb1eb.tar.bz2
Improve parsedate & related MH formats
* libmailutils/datetime/parsedate.y (spec production): If a non-signed number is given, treat it as a (positive) timezone, unless tz is already set, or as a year number, unless a year is already set, or throw an error otherwise. (mu_parse_date_dtl): Revert sign of the returned utc_offset * mh/mh_format.c (builtin_tzone): Compatibility fix * mh/tests/fmtfunc.at: Test more functions.
Diffstat (limited to 'mh')
-rw-r--r--mh/mh_format.c35
-rw-r--r--mh/tests/fmtfunc.at49
2 files changed, 58 insertions, 26 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 3948be49f..1278bfa28 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -1104,29 +1104,32 @@ static void
builtin_tzone (struct mh_fvm *mach)
{
struct mu_timezone tz;
+ char buf[6];
+ int s;
+ unsigned hrs;
_parse_date (mach, NULL, &tz, NULL);
-
+
+#if 0
+ /* FIXME: If symbolic tz representation is needed, we'd do: */
if (tz.tz_name)
mh_string_load (&mach->str[R_REG], tz.tz_name);
else
- {
- char buf[6];
- int s;
- unsigned hrs;
+ /* .... */
+ /* However, MH's tzone function simply formats the timezone */
+#endif
- if (tz.utc_offset < 0)
- {
- s = '-';
- tz.utc_offset = - tz.utc_offset;
- }
- else
- s = '+';
- hrs = tz.utc_offset / 3600;
- snprintf (buf, sizeof buf, "%c%02u%02u", s,
- hrs, (tz.utc_offset - hrs * 3600) / 60);
- mh_string_load (&mach->str[R_REG], buf);
+ if (tz.utc_offset < 0)
+ {
+ s = '-';
+ tz.utc_offset = - tz.utc_offset;
}
+ else
+ s = '+';
+ hrs = tz.utc_offset / 3600;
+ snprintf (buf, sizeof buf, "%c%02u%02u", s,
+ hrs, (tz.utc_offset - hrs * 3600) / 60);
+ mh_string_load (&mach->str[R_REG], buf);
}
/* szone date integer timezone explicit?
diff --git a/mh/tests/fmtfunc.at b/mh/tests/fmtfunc.at
index 8f8b81c27..07be0e07d 100644
--- a/mh/tests/fmtfunc.at
+++ b/mh/tests/fmtfunc.at
@@ -464,7 +464,17 @@ FMTFUNC([weekday],
[Monday
])
-# FIXME: sday
+FMTFUNC([sday],
+[%(sday{Date})
+%(sday{X-Date})
+],
+[Date: Mon, 3 Jul 2017 13:17:58 +0300
+X-Date: 3 Jul 2017 13:17:58 +0300
+
+],
+[1
+0
+])
FMTFUNC([mday],
[%(mday{Date})
@@ -522,17 +532,36 @@ FMTFUNC([year],
# FIXME: zone
-# FIXME: This returns EEST if tz files are properly set
-# FMTFUNC([tzone],
-# [%(tzone{Date})
-# ],
-# [Date: Mon, 3 Jul 2017 13:17:58 +0300
+FMTFUNC([tzone],
+[%(tzone{Date})
+%(tzone{X-Date-1})
+%(tzone{X-Date-2})
+%(tzone{X-Date-3})
+],
+[Date: Mon, 3 Jul 2017 13:17:58 +0300
+X-Date-1: Mon, 3 Jul 2017 13:17:58 -0500
+X-Date-2: Mon, 3 Jul 2017 13:17:58 +0000
+X-Date-3: Mon, 3 Jul 2017 13:17:58 0000
-# ],
-# [+0300
-# ])
-# FIXME: szone
+],
+[+0300
+-0500
++0000
++0000
+])
+
+FMTFUNC([szone],
+[%(szone{Date})
+%(szone{X-Date})
+],
+[Date: Mon, 3 Jul 2017 13:17:58 +0300
+X-Date: Mon, 3 Jul 2017 13:17:58
+
+],
+[1
+0
+])
# FIXME: date2local

Return to:

Send suggestions and report system problems to the System administrator.