Comment 3 for bug 1262657

Revision history for this message
Eitan (emosenkis) wrote :

Looks pretty good. I made a few changes:
1. replaced camelCase getTransitions with lowercase transitions to match the style of the rest of the public API.
2. return 'sequence' instead of 'list' to allow it to be implemented as a generator if you so choose
3. return timedeltas instead of just a number of minutes
4. attempted to tersely make clear that it always returns at least one transition, starting from the latest transition that is <= min.

def transitions(self, min, max):
    '''
    Return a sequnce of one or more daylight savings transitions that cover the given period, as (utc_datetime, offset) tuples. offset is a datetime.timedelta from UTC.

    min and max are datetime instances. If no timezone information is attached, they are assumed to be UTC.

    The utc_datetime of the first transition returned will be less than or equal to min such that the first offset is equal to utcoffset(min). The utc_datetime of the last transition returned will be less than or equal to max such that the last offset is equal to utcoffset(max).

    If no transitions occur between min and max inclusive, a sequence will be returned containing the last transition that occurs before min.
   '''