Calculate weekday
parent
037ff86e4f
commit
53e45a1c3c
4
gui.lua
4
gui.lua
|
@ -31,8 +31,7 @@ local function show_calendar(player_name, ordinal, wanted_months, wanted_years)
|
|||
wanted_dmonths = wanted_dmonths + 1
|
||||
wanted_dyears = wanted_dyears + 1
|
||||
end
|
||||
local weekday = 0
|
||||
local formspec = "formspec_version[3]size["..(calendar.WEEK_DAYS+2)..",9]"
|
||||
local formspec = "formspec_version[3]size["..(calendar.WEEK_DAYS+2)..",10]"
|
||||
if ordinal then
|
||||
formspec = formspec .. "label[0.5,0.5;"..F(S("@1, year @2", calendar.month_names[wanted_months+1], wanted_dyears)).."]"
|
||||
else
|
||||
|
@ -42,6 +41,7 @@ local function show_calendar(player_name, ordinal, wanted_months, wanted_years)
|
|||
local tdays = 0
|
||||
tdays = tdays + wanted_years * (calendar.MONTHS * calendar.MONTH_DAYS)
|
||||
tdays = tdays + wanted_months * calendar.MONTH_DAYS
|
||||
local weekday = calendar.get_weekday(tdays)
|
||||
|
||||
local x, y = 0.75, 1.2
|
||||
for w=1, #calendar.weekday_names_short do
|
||||
|
|
7
init.lua
7
init.lua
|
@ -23,6 +23,7 @@ calendar.YEAR_DAYS = calendar.MONTHS * calendar.MONTH_DAYS
|
|||
calendar.weekday_names = { S("Monday"), S("Tuesday"), S("Wednesday"), S("Thursday"), S("Friday"), S("Saturday"), S("Sunday") }
|
||||
calendar.weekday_names_short = { S("Mo"), S("Tu"), S("We"), S("Th"), S("Fr"), S("Sa"), S("Su") }
|
||||
calendar.WEEK_DAYS = #calendar.weekday_names
|
||||
calendar.FIRST_WEEK_DAY = 0
|
||||
|
||||
local holidays = {
|
||||
{ name = S("New Year's Eve"),
|
||||
|
@ -67,6 +68,12 @@ calendar.get_holidays = function(total_days)
|
|||
return found_holidays
|
||||
end
|
||||
|
||||
-- Returny weekday number
|
||||
-- * total_days: elapsed days since start of world
|
||||
calendar.get_weekday = function(total_days)
|
||||
return (total_days + calendar.FIRST_WEEK_DAY) % calendar.WEEK_DAYS
|
||||
end
|
||||
|
||||
-- Returns day, month, year, days in year
|
||||
-- * days: elapsed days since start of world
|
||||
-- * ordinal: if true, use ordinal numbers (day, month, year start counting at 1).
|
||||
|
|
Loading…
Reference in New Issue