tango-controls / fandango

Functional tools for PyTango / Tango Control System http://www.tango-controls.org/resources/howto/how-fandango/
7 stars 9 forks source link

Exception in str2time method #11

Closed cmft closed 5 years ago

cmft commented 5 years ago

In Fandango 14.1.0, str2time raises an exception when you do not specified the minutes in the date format: e.g.

from fandango.functional import str2time
str2time('2018-11-20T14')
#Exception: ('PARAMS_ERROR', 'date format cannot be parsed!: 2018-11-20T14')

However without the seconds works

str2time('2018-11-20T14:00')
sergirubio commented 5 years ago

Well, the problem is the 'T' in the string.

str2time assume's few standard date formats accepted by mysql and posgresql; if you are using your own custom format then you should pass it as argument to the function:

fn.str2time('2018-11-20T14:00', cad='%Y-%m-%dT%H:%M')

On 11/26/18 4:22 PM, Carlos Falcon wrote:

In Fandango 14.1.0, |str2time| raises an exception when you do not specified the minutes in the date format: e.g.

|from fandango.functional import str2time str2time('2018-11-20T14')

Exception: ('PARAMS_ERROR', 'date format cannot be parsed!:

2018-11-20T14') |

However without the seconds works

|str2time('2018-11-20T14:00') |

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tango-controls/fandango/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/ARkKqb-7u97zy-OfPZIt34NLqIgb_BQ8ks5uzAdQgaJpZM4YzPtT.

sergirubio commented 5 years ago

I'll close this issue and create a new one relative to supporting ISO-8061 on time conversions Until then, use the custom format argument

cmft commented 5 years ago

It is not a custom representation; it follows ISO-8601. And in somehow you support it cause it works as it is expected : str2time('2018-11-20T14:00')

Ok

sergirubio commented 5 years ago

but not as default, time2str and str2time are expected to be symetric I will add fandango.functional.DEFAULT_TIME_FORMAT to manage this symmetry