parse_timestamp: accept RFC3339-style timezone and %FT%R[:%S[.%N]]
We basically parsed the RFC3339 format already, except with a space:
NOTE: ISO 8601 defines date and time separated by "T".
Applications using this syntax may choose, for the sake of
readability, to specify a full-date and full-time separated by
(say) a space character.
so now we handle both
2012-11-23 11:12:13.456
2012-11-23T11:12:13.456
as equivalent.
Parse directly-suffixed Z and +05:30 timezones as well:
2012-11-23T11:12:13.456Z
2012-11-23T11:12:13.456+02:00
as they're both defined by RFC3339.
We do /not/ allow z or t; the RFC says
NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
syntax may alternatively be lower case "t" or "z" respectively.
This date/time format may be used in some environments or contexts
that distinguish between the upper- and lower-case letters 'A'-'Z'
and 'a'-'z' (e.g. XML). Specifications that use this format in
such environments MAY further limit the date/time syntax so that
the letters 'T' and 'Z' used in the date/time syntax must always
be upper case. Applications that generate this format SHOULD use
upper case letters.
We /are/ in a case-sensitive environment, neither are in wide-spread
use, and "z" poses an issue of whether "todayz" should be the same
as "todayZ" ("today UTC") or an error (it should be an error).
Fractional seconds are limited to six digits (they're nominally
time-secfrac = "." 1*DIGIT
), since we only support 1µs-resolution timestamps, and limit to six
digits in our other sub-second formats.
Parsing
2012-11-23T11:12
is an extension two ways (no seconds, no timezone),
mirroring our "canonical" format.
Fixes #5194
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
82b7bf8c1c
commit
ef658a63f8
@@ -110,7 +110,10 @@
|
||||
|
||||
<para>When parsing, systemd will accept a similar syntax, but expects no timezone specification, unless
|
||||
it is given as the literal string <literal>UTC</literal> (for the UTC timezone), or is specified to be
|
||||
the locally configured timezone, or the timezone name in the IANA timezone database format. The complete
|
||||
the locally configured timezone, the timezone name in the IANA timezone database format,
|
||||
or in the <ulink url="https://tools.ietf.org/html/rfc3339">RFC 3339</ulink> profile of ISO 8601, as
|
||||
<literal>Z</literal> or <literal>+<replaceable>05</replaceable>:<replaceable>30</replaceable></literal>
|
||||
appended directly after the timestamp. The complete
|
||||
list of timezones supported on your system can be obtained using the <literal>timedatectl
|
||||
list-timezones</literal> (see
|
||||
<citerefentry><refentrytitle>timedatectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>). Using
|
||||
@@ -154,6 +157,8 @@
|
||||
<programlisting> Fri 2012-11-23 11:12:13 → Fri 2012-11-23 11:12:13
|
||||
2012-11-23 11:12:13 → Fri 2012-11-23 11:12:13
|
||||
2012-11-23 11:12:13 UTC → Fri 2012-11-23 19:12:13
|
||||
2012-11-23T11:12:13Z → Fri 2012-11-23 19:12:13
|
||||
2012-11-23T11:12+02:00 → Fri 2012-11-23 17:12:00
|
||||
2012-11-23 → Fri 2012-11-23 00:00:00
|
||||
12-11-23 → Fri 2012-11-23 00:00:00
|
||||
11:12:13 → Fri 2012-11-23 11:12:13
|
||||
|
||||
Reference in New Issue
Block a user