MCPcopy Create free account
hub / github.com/ActiveState/code / GetDate

Method GetDate

recipes/Python/473841_A_simple_date_class_/recipe-473841.py:100–112  ·  view source on GitHub ↗
(self, form=None)

Source from the content-addressed store, hash-verified

98 raise 'bad format'
99
100 def GetDate(self, form=None):
101 if form is None:
102 form = self.__form
103 if form == format.mdyy:
104 return str(self.__month)[-2:].zfill(2) + '/' + str(self.__day)[-2:].zfill(2) + '/' + str(self.__year)[-4:].zfill(4)
105 elif form == format.yymd:
106 return str(self.__year)[-4:].zfill(4) + '/' + str(self.__month)[-2:].zfill(2) + '/' + str(self.__day)[-2:].zfill(2)
107 elif form == format.mdy:
108 return str(self.__month)[-2:].zfill(2) + '/' + str(self.__day)[-2:].zfill(2) + '/' + str(self.__year)[-2:].zfill(2)
109 elif form == format.ymd:
110 return str(self.__year)[-2:].zfill(2) + '/' + str(self.__month)[-2:].zfill(2) + '/' + str(self.__day)[-2:].zfill(2)
111 else:
112 raise 'bad format'
113
114 def GetDateShort(self):
115 return time.strftime('%a %b %d, %Y', time.strptime(self.GetDate(format.mdyy), '%m/%d/%Y'))

Callers 7

GetDateShortMethod · 0.95
GetDateLongMethod · 0.95
GetDayOfWeekMethod · 0.95
GetJulianDayMethod · 0.95
IsValidMethod · 0.95
AddDaysMethod · 0.95
__get_relative_dayMethod · 0.95

Calls 1

strFunction · 0.85

Tested by

no test coverage detected