Ignore:
Timestamp:
Jun 7, 2014, 11:32:31 PM (5 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Expect time shift in 15-minute units, not hour units (ticket #81).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1506 r1511  
    303303        absolute_time_shift = abs(time_shift)
    304304        signum = time_shift / absolute_time_shift
    305         # Round it to hours. This code should also work for later Python
    306         # versions because of the explicit `int`.
    307         absolute_rounded_time_shift = \
    308           int( (absolute_time_shift + 30*minute) / hour ) * hour
     305        # Round absolute time shift to 15-minute units.
     306        absolute_rounded_time_shift = (
     307          int( (absolute_time_shift + (7.5*minute)) / (15.0*minute) ) *
     308          (15.0*minute))
    309309        # Return with correct sign.
    310310        return signum * absolute_rounded_time_shift
     
    326326                  "time shift abs({0:.2f} s) > 1 day".format(time_shift))
    327327        # Test 2: Fail if the deviation between given time shift and
    328         #         full hours is greater than a certain limit.
     328        #         15-minute units is greater than a certain limit.
    329329        maximum_deviation = 5 * minute
    330330        if abs(time_shift - self.__rounded_time_shift(time_shift)) > \
     
    332332            raise ftputil.error.TimeShiftError(
    333333                    "time shift ({0:.2f} s) deviates more than {1:d} s "
    334                     "from full hours".format(
     334                    "from 15-minute units".format(
    335335                      time_shift, int(maximum_deviation)))
    336336
Note: See TracChangeset for help on using the changeset viewer.