def updateEndDates(self): (y, m, d) = self.startDateInput.get_value() jd0 = to_jd(y, m, d, self.altMode) - 1 for row in self.trees: mLen = row[3] jd0 += mLen row[4] = dateLocale(*jd_to(jd0, self.altMode))
def updateVars(self): (y, m, d) = self.startDateInput.get_value() monthDb.endJd = monthDb.startJd = to_jd(y, m, d, self.altMode) monthDb.monthLenByYm = {} for row in self.trees: ym = row[0] mLen = row[3] monthDb.monthLenByYm[ym] = mLen monthDb.endJd += mLen monthDb.save()
def changeDate(year, month, day, mode=None): global cell if mode is None: mode = calTypes.primary cell = cellCache.getCell(core.to_jd(year, month, day, mode))
def changeDate(year, month, day, mode=None): global cell if mode is None: mode = core.primaryMode cell = cellCache.getCell(core.to_jd(year, month, day, mode))
def getCellByDate(self, year, month, day): return self.getCell(core.to_jd(year, month, day, core.primaryMode))
def buildStatus(self, year, month, addCache=True): #print 'Building cache (%s, %s)'%(year, month) s = MonthStatus()#s = [] s.year = year s.month = month pyear = year pmonth = month -1 if pmonth <= 0 : pmonth =12 pyear -=1 prevMonthLen = core.getMonthLen(pyear, pmonth, self.mode) currentMonthLen = core.getMonthLen(year, month, self.mode) s.monthLen = currentMonthLen ##################### s.weekNum = [self.weekNumber(year, month, 1+7*i) for i in xrange(6)] offset = core.getWeekDay(year, month, 1) if offset==0: ###### Which Method ???????????????????? #day = prevMonthLen - 6 ; s.weekNum = [self.weekNumber(year, month, 1+7*i)-1 for i in xrange(6)] day = 1 else: day = prevMonthLen - offset + 1 s.monthStartOffset = offset ###################### for i in xrange(6): s.append([]) for j in xrange(7): c = Cell() c.pos = (j, i) s[i].append(c) c.jd = core.to_jd(year, month, day, self.mode) if i<2 and day>15: c.gray = -1 c.date = (pyear, pmonth, day) #c.ym = (pyear, pmonth) elif i>=4 and day<20: c.gray = 1 nyear = year nmonth = month +1 if nmonth > 12 : nmonth =1 nyear += 1 c.date = (nyear, nmonth, day) else: c.gray = 0 c.date = (year, month, day) cyear, cmonth, cday = c.date if c.gray==0: wd = (core.firstWeekDay + j) % 7 ##?????????? if wd in self.holidayWeekDays: c.holiday = True day+=1 if i>3 and day>currentMonthLen: day =1 sday=1 if i<2 and day>prevMonthLen: day =1 if addCache: ## Clean Cache n = len(self.months) #print 'Cache size: %s'%n if n >= self.maxCache: keys = self.months.keys() keys.sort() if keys[n/2] < (year, month): rm = keys[0] if rm==self.today[:2]: rm = keys[1] else: rm = keys[-1] if rm==self.today[:2]: rm = keys[-2] #if rm != (year, month): #print 'Removing cache (%s, %s)'%(rm[0], rm[1]) self.months.pop(rm) try:#### for memory emhancement del self.months[(year, month)] except: pass self.months[(year, month)] = s return s