Hello Michelle, Michelle Konzack wrote: > thank you for your answer, but if I use > date --date="2009-10-19 00:00:01 AM" --rfc-822 > I get the error: > date: invalid date `2009-10-19 00:00:01 AM'
Ah... I misunderstood your question. Sorry about that. I had
thought you were asking if 00:00:01 was AM or PM and not whether date
should parse it.
With this clarification first I would say that I would not consider
"2009-10-19 00:00:01 AM" to be a valid US time string with a "00" hour
and followed by "AM" or "PM". The "00" would only be seen with
24-hour time and 24-hour time never has a AM/PM qualifier. Although
times written by people have a large poetic license for creative
constructs and people can sometimes be very creative. :-)
In regards to date parsing, in the GNU Coreutils date manual in the
"Time of day items" node it says:
If the time is followed by `am' or `pm' (or `a.m.' or `p.m.'), HOUR
is restricted to run from 1 to 12, and `:MINUTE' may be omitted (taken
to be zero). `am' indicates the first half of the day, `pm' indicates
the second half of the day. In this notation, 12 is the predecessor of
1: midnight is `12am' while noon is `12pm'. (This is the zero-oriented
interpretation of `12am' and `12pm', as opposed to the old tradition
derived from Latin which uses `12m' for noon and `12pm' for midnight.)
This is why an hour of "00" is invalid when followed by "AM" but "01"
is okay. It should be "12" in that "00" case.
$ date --date="2009-10-19 12:00:01 AM" --rfc-822
Mon, 19 Oct 2009 00:00:01 -0600
Does that satisfactorily resolve the issue?
Bob
signature.asc
Description: Digital signature

