wroberts / pytimeparse

A small Python module to parse various kinds of time expressions.
MIT License
287 stars 39 forks source link

Doesn't have a default time unit when given just a number #20

Open baadal-bharosa opened 5 years ago

baadal-bharosa commented 5 years ago

If we do parse("10"), it returns None. Maybe the module should define (or have a setting) for a default time unit. That way we get a predictable output.

cackovic commented 5 years ago

I feel that returning None is a predictable output.

baadal-bharosa commented 5 years ago

Sorry for not expressing the thought fully. By "predictable output" what I implied was to get an output that is still a function of the input. Instead of None which is invariant.

The module addresses most of the issues with respect to processing various possible formats of specifying the time. Only thing I found missing was what I mentioned above - when we give it a number without any format hints.

To overcome this, the user will have to check the input and add some default format hint.

I felt that adding this support makes the module more comprehensive.

markusressel commented 5 years ago

Yeah I feel like a simple number should be parsed as plain seconds.