While testing/reviewing my nearly finished updates for my technoteattachcli branch following the
comments from Ross, I discovered that if I try creating tech notes with dates before 1 BC or after
AD 9999 resulting in the error message "Internal error: Fossil tried to make an invalid artifact for
the edited technote."
This is caused by an assumption in the code that the ISO 8601 formatted date has a four digit year.
This assumption is also backed up by the SQLite documentation for the DATETIME functions which
explicitly states that "For dates outside that range, the results of these functions are undefined."
I'm not sure how to proceed as I see three options for all of which I can make
a case:
1. Leave as is. In practice, dates outside of the supported range will not be used so the internal
error is a non-problem (It's unlikely that fossil would be used to attempt to record events in human
history which is a scenario which could want to use dates that cause the internal error).
2. Add error checking to both the CLI and GUI so that the error message is more explicit and isn't
an internal error. However without effectively reimplementing some of the logic from DATETIME, the
error checking code would end up relying on the undefined behaviour of the julianday function.
3. Remove the assumption from the code that the output from datetime has a four digit year number
and hence support dates outside of the supported range as long as the undefined result from datetime
gives a string.
My initial temptation was to implement option 3, but (a) relying on undefined behaviour feels just
wrong and (b) doesn't actually add that much to the available range of dates (my testing on Ubuntu
showed that datetime returns sensible results between 4713 BC and 28052 AD).
I've almost certainly been over thinking this, so does anyone else have thoughts or opinions on what
is sensible for fossil?
Dave
_______________________________________________
fossil-dev mailing list
fossil-dev@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/fossil-dev