sorcery  Artifact [9f638b5b65]

Artifact 9f638b5b65b92381bba75652d0a08d034efb6ab87c1a72e2a0a31bcf3122d50d:

  • File data/calendar.lua — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 1796) [annotate] [blame] [check-ins using]

-- 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;
		}
	}
}