drKlauz wrote: ↑
Sat Jun 22, 2019 6:40 pm
Come to think about it, it may be better to manually construct time/date strings, as python uses player's machine locale, so if some german or russian guy play your game, it may return something you not expecting, many fonts don't support glyphs for these languages, also layout may become visually broken.
Just replace code inside time_str/date_str to something similar to daymark.
Anyway, good luck with you game
Oh! With everything on the go.... I never thought of that until you mentioned it. I was reading a post found on stackoverflow.com site in regards of locale.
Taken from that site: START of copied text ----
Link -> to page on stackoverflow.com
(about halfway down the page)
Python's strftime() is only guaranteed to support the format codes from C89 (see the list).
Useful additional format codes are defined by other standards (see the Linux man page for strftime()). For this question, the relevant additional codes are:
%l — The hour (12-hour clock) as a decimal number (range 1 to 12).
%P — Like %p but in lowercase: "am" or "pm" or a corresponding string for the current locale.
I like to use a wrapper function around strftime() to implement additional codes:
Code: Select all
def extendedStrftime(dt, format):
day = dt.strftime('%d').lstrip('0')
hour = dt.strftime('%I').lstrip('0')
ampm = dt.strftime('%p').lower()
format = format.replace('%e', day)
format = format.replace('%l', hour)
format = format.replace('%P', ampm)
To get an output in the format "2:35pm":
It's also very common to want to format the day without the leading zero, which can be done with the additional code %e:
extendedStrftime(dt, '%e %b %Y') # "1 Jan 2015"
--- END of copied text
Would this be something that would be acceptable in Ren'Py to make it compatible with other locales? The information that I'm finding is getting me confused in regards of different locales.
So much smoke coming out of my ears! I have been also trying to figure if I can use a IF Statement with the output of [gts.daymark] for an event. Meaning that it the gametime calculation is at 8:00AM then show an image.
I guess that it's only me that can take a post of "Scarily simple game calendar... with day parts" and make it "Scarily Complicated" lol
Just in case someone else is looking into this, here is the REVISED code
that I have so far:
Code: Select all
### Calendar System
def __init__(self, dt="Saturday April 29 2017"):
self._dt = datetime.datetime.strptime( dt, "%A %B %d, %Y" )
def alter(self, **kwargs):
self._dt += datetime.timedelta( **kwargs )
return _strftime("%I:%M %p %A %B %d,"" %Y", self._dt.timetuple())
@property ### [gts.daymark] Displays "Time Of Day" according to hour
return [ k[-1] for k in (
(1,2,3,4,5, "Very Early Morning"),
(6,7, "Early Morning"),
(16,17, "Late Afternoon"),
(22,23, "Late Night") ) if self._dt.hour in k ]
### "[gts.time_str]" Displays "Hours:Minutes AM OR PM"
return _strftime("%I:%M %p",self._dt.timetuple())
### "[gts.date_str]" Displays "Weekday, Month DayNumber, Year"
return _strftime("%A, %B %d, %Y",self._dt.timetuple())
### "[gts.date2_str]" Displays "Weekday, Month DayNumber"
return _strftime("%A, %B %d",self._dt.timetuple())
### "[gts]" Displays "Hours:Minutes AM OR PM Weekday, Month DayNumber, Year"
default gts = GameTime("Saturday April 29 2017")
# If you want to create an IF Statement event by using Time "hours"
# if gts._dt.hour==18:
# jump process_evening
# Super Thanks to drKlauz for the help!