class Time:
def __init__( self, hour = 0, minute = 0, second = 0 ):
self.setTime( hour, minute, second )
def setTime( self, hour, minute, second ):
self.setHour( hour )
self.setMinute( minute )
self.setSecond( second )
def setHour( self, hour ):
if 0 <= hour < 24:
self.__hour = hour
else:
raise ValueError, "Invalid hour value: %d" % hour
def setMinute( self, minute ):
if 0 <= minute < 60:
self.__minute = minute
else:
raise ValueError, "Invalid minute value: %d" % minute
def setSecond( self, second ):
if 0 <= second < 60:
self.__second = second
else:
raise ValueError, "Invalid second value: %d" % second
def getHour( self ):
return self.__hour
def getMinute( self ):
return self.__minute
def getSecond( self ):
return self.__second
def printMilitary( self ):
print "%.2d:%.2d:%.2d" % ( self.__hour, self.__minute, self.__second ),
def printStandard( self ):
standardTime = ""
if self.__hour == 0 or self.__hour == 12:
standardTime += "12:"
else:
standardTime += "%d:" % ( self.__hour % 12 )
standardTime += "%.2d:%.2d" % ( self.__minute, self.__second )
if self.__hour < 12:
standardTime += " AM"
else:
standardTime += " PM"
print standardTime,