tempo
tempo copied to clipboard
Restrict supported date interval
It looks like strptime and strftime behaviour for dates before 1900 varies across platforms, so I think we should throw an error on such inputs.
(tempo_dev@yooki)13> tempo:parse(<<"%Y">>, {unix, <<"1505">>}). %% OS X
{error,format_mismatch}
Besided undefined behaviour there is an obvious bug there:
(tempo_dev@si14-laptop)6> tempo:parse(<<"">>, <<"">>, unix).
{ok,0.0} <---- WAT
(tempo_dev@si14-laptop)7> tempo:parse(<<"%Y">>, {unix, <<"1505">>}).
{ok,-14674003200.0}
What kind of behaviour would you expect? I'd say badarg for both of them.
Yup.
The first case is fixed in 593cd5c38ca65d4f82c5182e1656af0d49f4958a, the latter is hard to validate, unfortunately. Any suggestions?