Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 37 lines (32 sloc) 1.178 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
import math

class TimeSlot:
    def __init__(self, dayOfWeek, startMinutes, endMinutes):
        self.DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
        self.dayOfWeek = dayOfWeek
        self.startMinutes = startMinutes
        self.endMinutes = endMinutes

    def compareTo(self, other):
        if self.dayOfWeek < other.dayOfWeek:
            return -1
        elif self.dayOfWeek > other.dayOfWeek:
            return 1
        else:
            if self.startMinutes < other.startMinutes:
                return -1
            elif self.startMinutes > other.startMinutes:
                return 1
        return 0

    def getDayOfWeek(self):
        return self.dayOfWeek

    def getDescription(self):
        return self.DAYS[self.dayOfWeek] + " " + self.getHrsMins(self.startMinutes) + "-" + self.getHrsMins(self.endMinutes)

    def getHrsMins(self, mins):
        hrs = math.floor(mins / 60)
        if hrs > 12:
            hrs -= 12
        remainder = math.floor(mins % 60)
        if remainder < 10:
            string_mins = "0" + str(remainder)
        else:
            string_mins = str(remainder)
        return str(hrs) + ":" + string_mins
Something went wrong with that request. Please try again.