@@ -7,6 +7,8 @@ init -1 python:
77
88 import json
99 import copy
10+ import calendar
11+
1012 from renpy.display.layout import Container
1113 from store.mas_calendar import CAL_TYPE_EV,CAL_TYPE_REP
1214
@@ -95,8 +97,14 @@ init -1 python:
9597 " November" , " December" ]
9698
9799 # Day names constant array
98- DAY_NAMES = [" Sunday" , " Monday" , " Tuesday" , " Wednesday" , " Thursday" ,
100+ DAY_NAMES_SUN = [" Sunday" , " Monday" , " Tuesday" , " Wednesday" , " Thursday" ,
99101 " Friday" , " Saturday" ]
102+ DAY_NAMES_MON = [" Monday" , " Tuesday" , " Wednesday" , " Thursday" ,
103+ " Friday" , " Saturday" , " Sunday" ]
104+ # Fallback
105+ DAY_NAMES = DAY_NAMES_SUN
106+
107+ FIRST_DAY_OF_WEEK = calendar.firstweekday()
100108
101109 # Events to which Calendar buttons will check for
102110 MOUSE_EVENTS = (
@@ -471,8 +479,17 @@ M̼̤̱͇̤ ͈̰̬͈̭ͅw̩̜͇͈ͅa̲̩̭̩ͅs̙ ̣͔͓͚̰h̠̯̫̼͉e̗̗̮r
471479 # call set up day buttons to fill up the calendar
472480 self ._setupDayButtons()
473481
482+ # Setup week format based on user's locale
483+ self ._setupWeekFormat()
474484
475-
485+ def _setupWeekFormat (self ):
486+ """
487+ Sets up week format (e.g. monday-sunday or sunday-saturday.)
488+ Falls back to sunday-saturday if first day of week isn't 0 or 6.
489+ """
490+ if self .FIRST_DAY_OF_WEEK == 0 :
491+ self .DAY_NAMES = self .DAY_NAMES_MON
492+ # Otherwise falls back to sunday-saturday
476493
477494 def _setupDayButtons (self ):
478495 """
@@ -537,7 +554,7 @@ M̼̤̱͇̤ ͈̰̬͈̭ͅw̩̜͇͈ͅa̲̩̭̩ͅs̙ ̣͔͓͚̰h̠̯̫̼͉e̗̗̮r
537554 first_day = datetime.datetime(self .selected_year, self .selected_month, 1 )
538555
539556 # get the first_day of the week that has the first day of current month
540- while first_day.weekday() != 6 :
557+ while first_day.weekday() != self .FIRST_DAY_OF_WEEK :
541558 first_day = first_day - day
542559
543560 # init the array that will hold the dates we're displaying
0 commit comments