The time epoch defined in settings can now be 0 (different from None).
The convert_gametime contrib now has a simple function to return gametime with units.
This commit is contained in:
parent
ee1fc0b648
commit
753bd35226
2 changed files with 21 additions and 1 deletions
|
|
@ -141,6 +141,25 @@ def realtime_to_gametime(secs=0, mins=0, hrs=0, days=0, weeks=0,
|
|||
return time_to_tuple(gtime, *units)
|
||||
return gtime
|
||||
|
||||
def custom_gametime(absolute=False):
|
||||
"""
|
||||
Return the game time as a tuple of units, as defined in settings.
|
||||
|
||||
Args:
|
||||
absolute (bool, optional): return the relative or absolute time.
|
||||
|
||||
Returns:
|
||||
The tuple describing the game time. The length of the tuple
|
||||
is related to the number of unique units defined in the
|
||||
settings. By default, the tuple would be (year, month,
|
||||
week, day, hour, minute, second).
|
||||
|
||||
"""
|
||||
current = gametime(absolute=absolute)
|
||||
units = sorted(set(UNITS.values()), reverse=True)
|
||||
del units[-1]
|
||||
return time_to_tuple(current, *units)
|
||||
|
||||
def real_seconds_until(**kwargs):
|
||||
"""
|
||||
Return the real seconds until game time.
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ def game_epoch():
|
|||
Get the game epoch.
|
||||
|
||||
"""
|
||||
return settings.TIME_GAME_EPOCH or server_epoch()
|
||||
game_epoch = settings.TIME_GAME_EPOCH
|
||||
return game_epoch if game_epoch is not None else server_epoch()
|
||||
|
||||
|
||||
def gametime(absolute=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue