I have to parse time-series data from CSV files in an application.
The timestamps sometimes are in locale time with DST transitions.
I want to use python-pendulum for the parsing of the date strings.
Is it possible to specify the dst_rule
when calling the pendulum.parse
method? It seems to be ignored:
>>> str(pendulum.parse('2017-10-29 02:30:00', tz='Europe/Berlin', dst_rule=pendulum.PRE_TRANSITION))
'2017-10-29T02:30:00+01:00'
>>> str(pendulum.parse('2017-10-29 02:30:00', tz='Europe/Berlin', dst_rule=pendulum.POST_TRANSITION))
'2017-10-29T02:30:00+01:00'
I need the first string to be '2017-10-29T02:30:00+02:00' in my application. Is there a way to achieve this?
I found a solution by instantiating the DateTime instance again after parsing:
Output now is
'2017-10-29T02:30:00+02:00'