Add register_holiday function

master
Wuzzy 2020-08-27 10:40:04 +02:00
parent 5015feb362
commit d3a7cf2d36
2 changed files with 19 additions and 33 deletions

View File

@ -12,7 +12,7 @@ local COLOR_DAYBOX_TODAY = "#FFFFFF80"
local player_current_calendars = {} local player_current_calendars = {}
local ORDINAL = false local ORDINAL = true
local function show_calendar(player_name, ordinal, wanted_months, wanted_years) local function show_calendar(player_name, ordinal, wanted_months, wanted_years)
local days, months, years = calendar.get_date() local days, months, years = calendar.get_date()
@ -33,9 +33,9 @@ local function show_calendar(player_name, ordinal, wanted_months, wanted_years)
end end
local formspec = "formspec_version[3]size["..(calendar.WEEK_DAYS+2)..",10]" local formspec = "formspec_version[3]size["..(calendar.WEEK_DAYS+2)..",10]"
if ordinal then if ordinal then
formspec = formspec .. "label[0.5,0.5;"..F(S("@1, year @2", calendar.month_names[wanted_months+1], wanted_dyears)).."]" formspec = formspec .. "label[0.5,0.5;"..F(S("Month @1, year @2", wanted_dmonths, wanted_dyears)).."]"
else else
formspec = formspec .. "label[0.5,0.5;"..F(S("@1, @2 years", calendar.month_names[wanted_months+1], wanted_dyears)).."]" formspec = formspec .. "label[0.5,0.5;"..F(S("@1 months, @2 years", wanted_dmonths, wanted_dyears)).."]"
end end
local start_day, end_day local start_day, end_day
local tdays = 0 local tdays = 0

View File

@ -25,36 +25,22 @@ calendar.weekday_names_short = { S("Mo"), S("Tu"), S("We"), S("Th"), S("Fr"), S(
calendar.WEEK_DAYS = #calendar.weekday_names calendar.WEEK_DAYS = #calendar.weekday_names
calendar.FIRST_WEEK_DAY = 0 calendar.FIRST_WEEK_DAY = 0
local holidays = { local holidays = {}
{ name = S("New Year's Eve"),
days = 0, -- Register a holiday.
months = 0 -- def: Table with these fields:
}, -- * name: Human-readable name
{ name = S("Lucky Day"), -- * days: Cardinal month day on which the holiday occurs
days = 7, -- * months: Cardinal month on which the holiday occurs
months = 7 calendar.register_holiday = function(def)
}, table.insert(holidays, def)
{ name = S("Bad Luck Day"), end
days = 13,
months = 2 calendar.register_holiday({
}, name = S("New Year's Eve"),
{ name = S("Boxing Day"), days = 0,
days = 23, months = 0
months = 11 })
},
{ name = S("Scary Day"),
days = 29,
months = 8
},
{ name = S("Fool's Day"),
days = 0,
months = 3
},
{ name = S("Sylvester"),
days = 29,
months = 11
},
}
calendar.get_holidays = function(total_days) calendar.get_holidays = function(total_days)
local days, months, years = calendar.get_date(total_days) local days, months, years = calendar.get_date(total_days)