mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-10-31 00:37:54 +00:00
Calendar fix
This commit is contained in:
parent
d15813630f
commit
144856d30a
2 changed files with 22 additions and 21 deletions
|
@ -1,6 +1,8 @@
|
|||
from toontown.toonbase import ToontownGlobals, TTLocalizer
|
||||
from toontown.parties import ToontownTimeZone
|
||||
import calendar, datetime
|
||||
|
||||
TIME_ZONE = ToontownTimeZone.ToontownTimeZone()
|
||||
TRICK_OR_TREAT = 0
|
||||
WINTER_CAROLING = 1
|
||||
CAROLING_REWARD = 100
|
||||
|
@ -92,36 +94,32 @@ def getHoliday(id):
|
|||
return Holidays.get(id, {})
|
||||
|
||||
def getServerTime(date):
|
||||
epoch = datetime.datetime.fromtimestamp(0, base.cr.toontownTimeManager.serverTimeZone)
|
||||
epoch = datetime.datetime.fromtimestamp(0, TIME_ZONE)
|
||||
delta = date - epoch
|
||||
|
||||
return delta.total_seconds()
|
||||
|
||||
def getStartDate(holiday, year=None):
|
||||
if 'startDate' in holiday:
|
||||
return holiday['startDate']
|
||||
def getStartDate(holiday, rightNow=None):
|
||||
if not rightNow:
|
||||
rightNow = datetime.datetime.now()
|
||||
|
||||
rightNow = datetime.datetime.now()
|
||||
startMonth = holiday['startMonth'] if 'startMonth' in holiday else (rightNow.month if 'weekDay' in holiday else 1)
|
||||
startMonth = holiday['startMonth'] if 'startMonth' in holiday else rightNow.month
|
||||
startDay = holiday['startDay'] if 'startDay' in holiday else (rightNow.day if 'weekDay' in holiday else calendar.monthrange(rightNow.year, startMonth)[0])
|
||||
startDate = datetime.datetime(year if year else rightNow.year, startMonth, startDay, tzinfo=base.cr.toontownTimeManager.serverTimeZone)
|
||||
holiday['startDate'] = startDate
|
||||
startDate = datetime.datetime(rightNow.year, startMonth, startDay, tzinfo=TIME_ZONE)
|
||||
|
||||
return startDate
|
||||
|
||||
def getEndDate(holiday, year=None):
|
||||
if 'endDate' in holiday:
|
||||
return holiday['endDate']
|
||||
def getEndDate(holiday, rightNow=None):
|
||||
if not rightNow:
|
||||
rightNow = datetime.datetime.now()
|
||||
|
||||
rightNow = datetime.datetime.now()
|
||||
endMonth = holiday['endMonth'] if 'endMonth' in holiday else (rightNow.month if 'weekDay' in holiday else 12)
|
||||
endMonth = holiday['endMonth'] if 'endMonth' in holiday else rightNow.month
|
||||
endDay = holiday['endDay'] if 'endDay' in holiday else (rightNow.day if 'weekDay' in holiday else calendar.monthrange(rightNow.year, endMonth)[1])
|
||||
endYear = year if year else rightNow.year
|
||||
endYear = rightNow.year
|
||||
|
||||
if 'startMonth' in holiday and holiday['startMonth'] > endMonth:
|
||||
endYear += 1
|
||||
|
||||
endDate = datetime.datetime(endYear, endMonth, endDay, tzinfo=base.cr.toontownTimeManager.serverTimeZone)
|
||||
holiday['endDate'] = endDate
|
||||
endDate = datetime.datetime(endYear, endMonth, endDay, tzinfo=TIME_ZONE)
|
||||
|
||||
return endDate
|
|
@ -161,22 +161,25 @@ class CalendarGuiDay(DirectFrame):
|
|||
if self.myDate.weekday() == holiday['weekDay']:
|
||||
self.addTitleAndDescToScrollList(title, description)
|
||||
elif 'startMonth' in holiday or 'startDay' in holiday:
|
||||
startDate = HolidayGlobals.getStartDate(holiday, self.myDate.year)
|
||||
endDate = HolidayGlobals.getEndDate(holiday, self.myDate.year)
|
||||
startDate = HolidayGlobals.getStartDate(holiday, self.myDate)
|
||||
endDate = HolidayGlobals.getEndDate(holiday, self.myDate)
|
||||
|
||||
if self.myDate.date() == startDate.date():
|
||||
if startDate.date() == endDate.date():
|
||||
if self.isDateMatch(self.myDate, startDate):
|
||||
if self.isDateMatch(startDate, endDate):
|
||||
description = '%s. %s' % (title, description)
|
||||
else:
|
||||
description = '%s. %s %s %s' % (title, description, TTLocalizer.CalendarEndsAt, endDate.strftime('%b %d'))
|
||||
|
||||
self.addTitleAndDescToScrollList(title, description)
|
||||
elif self.myDate.date() == endDate.date():
|
||||
elif self.isDateMatch(self.myDate, endDate):
|
||||
title = '%s %s' % (TTLocalizer.CalendarEndOf, title)
|
||||
description = '%s. %s %s' % (title, TTLocalizer.CalendarStartedOn, startDate.strftime('%b %d'))
|
||||
|
||||
self.addTitleAndDescToScrollList(title, description)
|
||||
|
||||
def isDateMatch(self, date1, date2):
|
||||
return date1.day == date2.day and date1.month == date2.month
|
||||
|
||||
def addTitleAndDescToScrollList(self, title, desc):
|
||||
textSize = self.ScrollListTextSize
|
||||
descTextSize = 0.05
|
||||
|
|
Loading…
Reference in a new issue