Ask HN: Know any validation libraries that guess whether a timestamp is in ms/s? When parsing timestamps, Pydantic (a wildly popular validation library for Python)
will infer for you whether it's in seconds or milliseconds.
I've never encountered behavior like this, and I wondered: Do you know of any other libraries, languages, or APIs that also do this type of inference? The reason is that it can result in surprising behavior for timestamps in 1970 and 1969:
(What's happening here is that timestamps close to 1970 are smaller,
and it infers that you must have meant to use seconds.) |