def normalize ( self , dt , is_dst = False ) : if dt . tzinfo is self : return dt if dt . tzinfo is None : raise ValueError ( 'Naive time - no tzinfo set' ) return dt . astimezone ( self )
python correcting incorrect timezone datetime
Correct the timezone information on the given datetime
def normalize(self, dt, is_dst=False):
        """Correct the timezone information on the given datetime"""
        if dt.tzinfo is self:
            return dt
        if dt.tzinfo is None:
            raise ValueError('Naive time - no tzinfo set')
        return dt.astimezone(self)