+2022-05-17 Paul Eggert <eggert@cs.ucla.edu>
+
+ parse-datetime: support 'J' military time zone
+ Requested by Brian Inglis in:
+ https://savannah.gnu.org/support/?110644
+ * lib/parse-datetime.y (parser_control): New member J_zones_seen.
+ (item): New item 'J'.
+ (military_table): Add 'J'.
+ (parse_datetime_body): Set and use J_zones_seen.
+ * tests/test-parse-datetime.c (main): Test "J".
+
2022-05-15 Reuben Thomas <rrt@sc3d.org>
doc: Update regex documentation to match implementation.
are obsolescent and are not recommended, because they
are ambiguous; for example, @samp{EST} has a different meaning in
Australia than in the United States, and @samp{A} has different
-meaning as a military time zone than as an obsolescent
+meaning as a military time zone than as an obsolete
RFC 822 time zone. Instead, it's better to use
unambiguous numeric time zone corrections like @samp{-0500}, as
described in the previous section.
bool rels_seen;
idx_t dates_seen;
idx_t days_seen;
+ idx_t J_zones_seen;
idx_t local_zones_seen;
idx_t dsts_seen;
idx_t times_seen;
pc->local_zones_seen++;
debug_print_current_time (_("local_zone"), pc);
}
+ | 'J'
+ {
+ pc->J_zones_seen++;
+ debug_print_current_time ("J", pc);
+ }
| zone
{
pc->zones_seen++;
RFC 822 got these backwards, but RFC 5322 makes the incorrect
treatment optional, so do them the right way here.
- Note 'T' is a special case, as it is used as the separator in ISO
+ 'J' is special, as it is local time.
+ 'T' is also special, as it is the separator in ISO
8601 date and time of day representation. */
static table const military_table[] =
{
{ "G", tZONE, HOUR ( 7) },
{ "H", tZONE, HOUR ( 8) },
{ "I", tZONE, HOUR ( 9) },
+ { "J", 'J', 0 },
{ "K", tZONE, HOUR (10) },
{ "L", tZONE, HOUR (11) },
{ "M", tZONE, HOUR (12) },
pc.dates_seen = 0;
pc.days_seen = 0;
pc.times_seen = 0;
+ pc.J_zones_seen = 0;
pc.local_zones_seen = 0;
pc.dsts_seen = 0;
pc.zones_seen = 0;
else
{
if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen
- | (pc.local_zones_seen + pc.zones_seen)))
+ | (pc.J_zones_seen + pc.local_zones_seen + pc.zones_seen)))
{
if (debugging (&pc))
{
dbg_printf ("error: seen multiple days parts\n");
if (pc.dsts_seen > 1)
dbg_printf ("error: seen multiple daylight-saving parts\n");
- if ((pc.local_zones_seen + pc.zones_seen) > 1)
+ if ((pc.J_zones_seen + pc.local_zones_seen + pc.zones_seen) > 1)
dbg_printf ("error: seen multiple time-zone parts\n");
}
goto fail;
ASSERT (expected.tv_sec == result.tv_sec
&& expected.tv_nsec == result.tv_nsec);
+ /* ISO 8601 extended date and time of day representation,
+ ' ' separator, 'J' (local) time zone */
+ p = "2011-05-01 11:55:18J";
+ expected.tv_sec = ref_time - gmtoff;
+ expected.tv_nsec = 0;
+ ASSERT (parse_datetime (&result, p, 0));
+ LOG (p, expected, result);
+ ASSERT (expected.tv_sec == result.tv_sec
+ && expected.tv_nsec == result.tv_nsec);
+
/* ISO 8601, extended date and time of day representation,
'T' separator, UTC */