sorcery  calendar.lua at [3f6a913e4e]

File data/calendar.lua artifact 9f638b5b65 part of check-in 3f6a913e4e


-- you can use your own month names and so on; even if you change
-- the length of the year the code will adapt

local days = {
	'Day of the Frozen River'; 'Day of Fell Shadow';
	'Day of Peaceful Splendor'; 'Day of Somber Reflection'; 
	'Day of Wrathful Visitation'; 'Day of Wistful Remembrance';
	'Day of the Warm Hearth'; 'Day of Joyous Worship';
	'Day of the Fond Farewell';
}

local weeks = {
	"Merchant's Week"; "Chandler's Week"; "Miller's Week";
	"Bard's Week"; "Cobbler's Week";
}

local moons = {
	'Splendormoon';
	'Embermoon';
	'Saddlemoon';
	'Candlemoon';
	'Cindermoon';
	'Diremoon';
	'Chancelmoon';
	'Starmoon';
	'Harvestmoon';
}

local yearadj = {
	'Whimpering';
	'Overturned';
	'Silent';
	'Whimsical';
	'Turbulent';
	'Parsimonius';
	'Rhadamanthine';
	'Exuberant';
	'Winsome';
	'Bifurcated';
}

local yearnoun = {
	'Princeling';
	'Applecart';
	'Oxcart';
	'Parsnip';
	'Lotus';
	'Daffodil';
}

local yg = function(y)
	local pos = -3
	local neg = y < 0
	y = tostring(math.abs(y))
	local n = ''
	while true do
		local w = string.sub(y,pos,pos+2)
		if w == nil or w == '' then break end 
		n = w .. ',' .. n
		pos = pos - 3
	end
	if neg then n = '-' .. n end
	return string.sub(n,1,-2)
end

return {
	days_per_stellar_cycle = 17;
	default = 'imperial';
	styles = {
		imperial = {
			name = 'Imperial Archipelagian Calendar';
			days = days, weeks = weeks, moons = moons;
			longdate = function(date)
				local day  = days [date.day_of_week ]
				local week = weeks[date.week_of_moon]
				local moon = moons[date.moon_of_year]
				return string.format('%s on %s in %s after %s years of the Imperial Revolution',day,week,moon,yg(date.year))
			end;
			shortdate = function(date)
				return string.format('%u/%u %s I.R.', date.day_of_moon, date.moon_of_year, yg(date.year))
			end;
		}
	}
}