Overview
| Artifact ID: | beddfeb2b90087f7a8517690803fcaf3c7e6526bedf5179c8348db127b97cf7e |
|---|---|
| Ticket: | f2b5f89c0d8520ea86b929daa19ec13fc3a24d2d
clock scan of leapsecond: wrong result in 8.6 and 9.0 |
| User & Date: | sebres on 2024-11-19 14:32:56 |
Changes
- icomment:
Again, this ISO amendment only affects the input side, the output of clock scan is and still remains the unix time, what simply doesn't know leap second, and so unable to represent it correctly at all.<br/> ISO can change something every year, and one can and probably must reflect it on the scanning of the input side, but not if the result of conversion is impossible in principle. I don't understand why you prefer a wrong result to the impossible result in case of -validate 1. Validity is basically a new mechanism to control whether the input is correct, but also and probably more important that the result is correct and the input was converted properly. And initially I implemented it in the way that the result was converted back and compared with input tokens and validation failed if the tokens deviated (what would happen in this particular case)... Later I reimplemented it more optimal by direct comparison, but it shall not change the principle - if back conversion generates different tokens than input, the simplest math doesn't work and the validation must fail. In my opinion the leap second is not such important thing, for which we shall make exceptions in this simple mechanic. I guess, there are also another corner cases what your branch doesn't consider at the moment and they could fail, for instance the check of the scanned weekday would probably fail (because of the day change, e. g. Sat to Sun): <code><pre style="padding-left:20pt"> % clock scan "Sat Jun 30 23:59:60 2012" -gmt 1 -valid 1 unable to convert input string: invalid day of week % clock scan "Sat Jun 30 23:59:60 2012" -format "%a %b %d %T %Y" -gmt 1 -valid 1 unable to convert input string: invalid day of week </pre></code> (untested, but I guess it will) In my opinion, a note in the documentation like this would be fully enough:<br/> <i>Since leap second is not representable in the result of scan (unix time), scan of time like <code>23:59:60</code> is generally impossible with -valid 1 (default in 9.0).</i><br/> That's it. Let alone that all programming languages doing it also. However if the decision will be nevertheless "let it be", I would recommend another variant to fix it - freeze the second in the same date: e. g. if the scanned second is 60 and date matches leap conditions, decrement time, so we'd remain in the same date and every validity rules, covering date tokens would be correct.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"