Module:Sandbox/Arcorann/Chinese time

This is an old revision of this page, as edited by Arcorann (talk | contribs) at 13:26, 27 September 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Load dependencies.
local mm = require('Module:Math')
local getArgs = require('Module:Arguments').getArgs

-- This module is intended to replace the entirety of Template:ctime and its subpages,
-- which may be found at https://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=ctime&namespace=10&stripprefix=1

local heavenlyStems = {
	{ '甲', 'Wood' },   -- 1
	{ '乙', 'Wood' },   -- 2
	{ '丙', 'Fire' },   -- 3
	{ '丁', 'Fire' },   -- 4
	{ '戊', 'Earth' },  -- 5
	{ '己', 'Earth' },  -- 6
	{ '庚', 'Metal' },  -- 7
	{ '辛', 'Metal' },  -- 8
	{ '壬', 'Water' },  -- 9
	{ '癸', 'Water' }   -- 10
}

local elements = {
	{ '甲', 'Wood' },   -- 1
	{ '乙', 'Wood' },   -- 2
	{ '丙', 'Fire' },   -- 3
	{ '丁', 'Fire' },   -- 4
	{ '戊', 'Earth' },  -- 5
	{ '己', 'Earth' },  -- 6
	{ '庚', 'Metal' },  -- 7
	{ '辛', 'Metal' },  -- 8
	{ '壬', 'Water' },  -- 9
	{ '癸', 'Water' }   -- 10
}

local earthlyBranches = {
	{ '子', '[[Rat (zodiac)|Rat]]' },           -- 1
	{ '丑', '[[Ox (zodiac)|Ox]]' },             -- 2
	{ '寅', '[[Tiger (zodiac)|Tiger]]' },       -- 3
	{ '卯', '[[Rabbit (zodiac)|Rabbit]]' },     -- 4
	{ '辰', '[[Dragon (zodiac)|Dragon]]' },     -- 5
	{ '巳', '[[Snake (zodiac)|Snake]]' },       -- 6
	{ '午', '[[Horse (zodiac)|Horse]]' },       -- 7
	{ '未', '[[Goat (zodiac)|Goat]]' },         -- 8
	{ '申', '[[Monkey (zodiac)|Monkey]]' },     -- 9
	{ '酉', '[[Rooster (zodiac)|Rooster]]' },   -- 10
	{ '戌', '[[Dog (zodiac)|Dog]]' },           -- 11
	{ '亥', '[[Pig (zodiac)|Pig]]' }            -- 12
}

local animals = {
	{ '子', '[[Rat (zodiac)|Rat]]' },           -- 1
	{ '丑', '[[Ox (zodiac)|Ox]]' },             -- 2
	{ '寅', '[[Tiger (zodiac)|Tiger]]' },       -- 3
	{ '卯', '[[Rabbit (zodiac)|Rabbit]]' },     -- 4
	{ '辰', '[[Dragon (zodiac)|Dragon]]' },     -- 5
	{ '巳', '[[Snake (zodiac)|Snake]]' },       -- 6
	{ '午', '[[Horse (zodiac)|Horse]]' },       -- 7
	{ '未', '[[Goat (zodiac)|Goat]]' },         -- 8
	{ '申', '[[Monkey (zodiac)|Monkey]]' },     -- 9
	{ '酉', '[[Rooster (zodiac)|Rooster]]' },   -- 10
	{ '戌', '[[Dog (zodiac)|Dog]]' },           -- 11
	{ '亥', '[[Pig (zodiac)|Pig]]' }            -- 12
}

local solar_terms = {
	{ '立春', '立春', 'lìchūn', 'start of spring' }, 		-- 315
	{ '雨水', '雨水', 'yǔshuǐ', 'rain water' },				-- 330
	{ '驚蟄', '惊蛰', 'jīngzhé', 'awakening of insects' }, 	-- 345
	{ '春分', '春分', 'chūnfēn', 'vernal equinox' },		-- 0
	{ '清明', '清明', 'qīngmíng', 'clear and bright' }		-- 15
}

-- local function parse_datetime(str)
-- 	-- converts a datetime into suitable format
-- end

local function stembranch_nums(pos)
	-- returns the stem and branch numbers in ordinal form, given ordinal position in cycle
	stem = (pos - 1)%10 + 1
	branch = (pos - 1)%12 + 1
	return {stem,branch}
end

local function time_to_dayfrac(time)
	-- Accepts a time formatted
end

local function dian(dayfrac)
	-- Accepts a day fraction
	-- Return the time in the diǎn system (60 diǎn in one day, beginning at midnight)
	-- replaces ctime:O
	return math.floor(dayfrac/60)
end

local function gengdian(dayfrac)
	-- Accepts a day fraction
	-- Return the time in the Gēngdiǎn system (10 gēng in one day, sāngēng begins at midnight)
	return 
end

local function ke(dayfrac)
	-- Returns the current kè under the 100-kè system
	return math.floor(dayfrac/100)
end