Class engine.Calendar
Defines calendars for factions
Fields
engine.Calendar.seconds_per_turn
Default: 10
engine.Calendar.MINUTE
Default: 6 turns = 60 / seconds_per_turn
engine.Calendar.HOUR
Default: 360 turns = MINUTE * 60
engine.Calendar.DAY
Default: 8640 turns = HOUR * 24
engine.Calendar.YEAR
Default: 3153600 turns = DAY * 365
engine.Calendar.DAY_START
Default: 2160 turns = HOUR * 6
Methods
engine.Calendar:init (definition, datestring, start_year, start_day, start_hour)
Create a calendar
engine.Calendar:getTimeDate (turn, dstr)
Gets a formatted timedate string
engine.Calendar:getDayOfYear (turn)
Get what day of the year it is based on turn
engine.Calendar:getTimeOfDay (turn)
Current time based on turn
engine.Calendar:getMonthNum (dayofyear)
Gets month number based on day of year
engine.Calendar:getMonthName (dayofyear)
Returns the name of the month using the day
engine.Calendar:getDayOfMonth (dayofyear)
Day of the month using day of year
engine.Calendar:getMonthLength (dayofyear)
How long the month is using day of year
Fields
- engine.Calendar.seconds_per_turn
- Default: 10
- engine.Calendar.MINUTE
- Default: 6 turns = 60 / seconds_per_turn
- engine.Calendar.HOUR
- Default: 360 turns = MINUTE * 60
- engine.Calendar.DAY
- Default: 8640 turns = HOUR * 24
- engine.Calendar.YEAR
- Default: 3153600 turns = DAY * 365
- engine.Calendar.DAY_START
- Default: 2160 turns = HOUR * 6
Methods
- engine.Calendar:init (definition, datestring, start_year, start_day, start_hour)
-
Create a calendar
Parameters:
- definition the file to load that returns a table containing calendar months
- datestring a string to format the date when requested, in the format "%s %s %s %d %d", standing for, day, month, year, hour, minute
- start_year the year the calendar starts at
- start_day defaults to 1
- start_hour defaults to 8
- engine.Calendar:getTimeDate (turn, dstr)
-
Gets a formatted timedate string
Parameters:
- turn int
- dstr string a datestring
Returns:
-
a formatted date string
- engine.Calendar:getDayOfYear (turn)
-
Get what day of the year it is based on turn
Parameters:
- turn int
Returns:
- dayofyear
- year
- engine.Calendar:getTimeOfDay (turn)
-
Current time based on turn
Parameters:
- turn int
Returns:
- hour
- min
- engine.Calendar:getMonthNum (dayofyear)
-
Gets month number based on day of year
Parameters:
- dayofyear int use getDayOfYear
Returns:
-
integer between {1, numMonths}
- engine.Calendar:getMonthName (dayofyear)
-
Returns the name of the month using the day
Parameters:
- dayofyear int use getDayOfYear
Returns:
-
month.name
- engine.Calendar:getDayOfMonth (dayofyear)
-
Day of the month using day of year
Parameters:
- dayofyear int getDayOfYear
Returns:
-
integer between {1, numDaysInMonth}
- engine.Calendar:getMonthLength (dayofyear)
-
How long the month is using day of year
Parameters:
- dayofyear int getDayOfYear
Returns:
-
month.length