I have written a code to deal with datetime but it is giving inconsistent results.:
def date_time_conversion(str_dt):
brussels = pytz.timezone("Europe/Brussels")
converted_date = datetime.strptime(str_dt, '%Y.%m.%d %H.%M.%S')
b = brussels.localize(converted_date)
return b
Whenever I run this code for any date before year 2037 it detects daylight saving time correctly. But Whenever I run it for any year post 2037 it fails to detect the daylight saving times
Example DST DETECTED:
date_time_conversion('2036.08.05 00:00:00')
output : datetime.datetime(2037, 8, 5, 0, 0, tzinfo =<DstTzInfo 'Europe/Brussels' CEST+2:00:00 DST>)
date_time_conversion('2036.01.05 00:00:00')
output : datetime.datetime(2037, 8, 5, 0, 0, tzinfo =<DstTzInfo 'Europe/Brussels' CET+1:00:00 STD>)
But for 2038 and any date after that :
Example DST NOT DETECTED:
date_time_conversion('2038.08.05 00:00:00')
output : datetime.datetime(2038, 5, 0, 0, 0, tzinfo =<DstTzInfo 'Europe/Brussels' CET+1:00:00 STD>)
date_time_conversion('2038.01.05 00:00:00')
output : datetime.datetime(2038, 1, 5, 0, 0, tzinfo =<DstTzInfo 'Europe/Brussels' CET+1:00:00 STD>)
Its my first time dealing with time zones so please pardon me for any silly logic errors.