SQLite Forum

Minor typo in documentation

Minor typo in documentation

(1) By Balaji Ramanathan (balaji) on 2021-03-17 23:02:32 [link] [source]

In the page on "Date and Time Functions" (https://sqlite.org/lang_datefunc.html), the explanation of format strings has the following detail about the %H modifier:

%H hour: 00-24

Is it supposed to be 00-23 rather than 00-24? I have tried various values of time, and different numbers of minutes and hours subtracted from them, but have never been able to get strftime to return 24 with %H. What would hour 24 even mean. I thought times in a day only go from 00:00:00 to 23:59:59. What does a time of 24:00:00 mean?

(2) By Larry Brasfield (larrybr) on 2021-03-18 00:01:53 in reply to 1 [link] [source]

Your observation of what the doc says is correct. However, opinions may vary on whether it represents a typo or a bug. It reflects what the functions do. And what they do is arguably in line with Postel's law, which urges leniency on input and rigor on output.

As an example for discussion consider this session screen-scrape: sqlite> select datetime( julianday('2000-01-01T24:59') ); 2000-01-02 00:59:00 . The result is sensible, and allows somebody who may be less than utterly familiar with the 24-hour time format to speak of the earliest morning hour without mention of the zero hour. (The fact that it's in the next day is another issue; the result is logical.)

There will be no mention of hour 24 in 24-hour output from the datetime/time functions. And whether somebody exploits the input leniency is up to them.

(3) By Balaji Ramanathan (balaji) on 2021-03-21 18:30:49 in reply to 2 [link] [source]

Ah, I see. So, allowance up to 24 is made to accommodate slightly erroneous input. I was looking at it purely from the output standpoint, and thought it was a typo in the documentation. Thank you.

(4) By Karl (kbilleter) on 2021-03-24 09:28:55 in reply to 3 [source]

According to https://en.wikipedia.org/wiki/24-hour_clock#Midnight_00:00_and_24:00 24 can make it clearer that your referring to midnight in the context of a day's end rather than beginning.