mirror of
https://github.com/krateng/maloja.git
synced 2026-05-26 17:42:34 -04:00
Moved date object patch to new module
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# custom json encoding
|
||||
|
||||
from simplejson import JSONEncoder
|
||||
|
||||
def newdefault(self,object):
|
||||
@@ -5,3 +7,25 @@ def newdefault(self,object):
|
||||
|
||||
olddefault = JSONEncoder.default
|
||||
JSONEncoder.default = newdefault
|
||||
|
||||
|
||||
|
||||
|
||||
# proper sunday-first weeks
|
||||
# damn iso heathens
|
||||
|
||||
from datetime import date, timedelta
|
||||
import datetime
|
||||
|
||||
class expandeddate(date):
|
||||
|
||||
def chrweekday(self):
|
||||
return self.isoweekday() + 1 % 7
|
||||
|
||||
def chrcalendar(self):
|
||||
tomorrow = self + timedelta(days=1)
|
||||
cal = tomorrow.isocalendar()
|
||||
return (cal[0],cal[1],cal[2] % 7)
|
||||
|
||||
|
||||
datetime.date = expandeddate
|
||||
|
||||
Reference in New Issue
Block a user