These are chronologically-order notes taken while working on that prototype to support dates (absolute and relative) in zodbtools' `<tidrange>`
# git's approxidate test "as is"
both python and go libraries do not support inputs like `1.month.ago`, so we preprocess to remove the `.`. (python's dateparser supports some formats though)
...
...
@@ -54,9 +57,80 @@ go run prototype/proto.go
no more errors reported.
# but is all this really a good idea ?
As we could see go and python have small differences, but it's OK.
One problem is that it (especially python's dateparser) does not report errors on invalid input, but almost always parse something. It has a `STRICT_PARSING` option, but it still allows invalid inputs (and cause different behavior on some relative dates), basically when the output contains numbers, the parser will return a date ...
for example with these inputs:
```
### some invalid formats that "looks OK"
# wrong format on timezone (should be 2009-06-01T22:00:00+09:00)
But with valid inputs, current implementations de-facto support so many formats, so for users who don't read the manual, it seem the tool support "any format and it will magically work", but sometimes it will not do what they think and cause bad surprises.
The original need was to support using date in tidrange, without having to "calculate" the tid from hash.
Relative dates are a cool feature, but I feel the most common use cases would be to use absolute dates.
If we only supported only one simple format (ISO8601), we would be able to detect and refuse invalid inputs.
That said, this is a tool for power users, so maybe that's OK as is. All these arguments exists for any powerful but dangerous tools such as using chainsaw to cut wood faster or cars to move faster, maybe we should not worry here.
While thinking about this, I checked unix `date` command and realized it also supports "clever" time parsing, for example:
```bash
date-d yesterday --iso-8601=seconds --utc
```
with `prototype/proto_unix_date.py` to check support for the reference dates: