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

Method weekday

recipes/Python/117215_A_Date_module/recipe-117215.py:119–131  ·  view source on GitHub ↗

Returns the weekday of the date. The format is as in the time module: Monday is 0 and sunday is 6.

(self)

Source from the content-addressed store, hash-verified

117 self.year, self.month, self.day = t[:3]
118
119 def weekday(self):
120 """Returns the weekday of the date.
121
122 The format is as in the time module: Monday is 0 and sunday is 6."""
123 a = (14 - self.month)//12
124 y = self.year - a
125 m = self.month + 12*a -2
126 d = (self.day + y + y//4 - y//100 + y//400 + (31*m//12))%7
127 if d:
128 ret = d - 1
129 else:
130 ret = 6
131 return ret
132
133 def __str__(self):
134 return "%s, %d-%s-%d" % (Date.Weekdays[self.weekday()],

Callers 4

__str__Method · 0.95
GetWeekdayMethod · 0.95
ToTimeTupleMethod · 0.95
dow_date_finderFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected