ceil time entry to nearest quarter hour

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    def getHours(self):
        """returns floating point hours rounded up to the nearest quarter hour"""
        td = self.end_time - self.start_time
        hours = td.seconds // 3600
        minutes = (td.seconds % 3600) // 60
        dec = (float(minutes) / 60)
        quarter = dec // 0.25
        if ((dec % 0.25) > 0):
            quarter += 0.25
        return hours + quarter

More like this

  1. DateTimeFluxCapacitor by jbcurtin 1 year ago
  2. Custom model field for mysql time type. by xuqingkuang 2 years, 3 months ago
  3. Time toggle on mouseover template filter by soniiic 2 years, 9 months ago
  4. SplitSelectDateTimeWidget by bradmontgomery 3 years, 2 months ago
  5. Hours of Operation Middleware by andrew 2 years, 11 months ago

Comments

(Forgotten your password?)