Ticket #22598: timezone.diff

File timezone.diff, 943 bytes (added by trott@…, 11 years ago)

patch for utils/timezone.py

  • Django-1.5.5/django/utils/timezone.py

    diff -r c1387e7748f1 .DS_Store
    Binary file .DS_Store has changed
    diff -r c1387e7748f1 Django-1.5.5/django/utils/timezone.py
    a b  
    277277    """
    278278    if hasattr(timezone, 'localize'):
    279279        # available for pytz time zones
    280         return timezone.localize(value, is_dst=None)
     280        #return timezone.localize(value, is_dst=None)
     281
     282        # TRott: may throw AmbiguousTimeError (eg. 2013-10-27 02:05:35)
     283        try:
     284            return timezone.localize(value, is_dst=None)
     285        except pytz.AmbiguousTimeError:
     286            return timezone.localize(value, is_dst=False)
     287        except pytz.NonExistentTimeError:
     288            return timezone.localize(value, is_dst=False)
    281289    else:
    282290        # may be wrong around DST changes
    283291        return value.replace(tzinfo=timezone)
Back to Top