Module:Sandbox/Arcorann/Chinese time

From English Wikipedia @ Freddythechick
-- 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 = {
	{ '甲', 'jiǎ' },   -- 1
	{ '乙', 'yǐ' },   -- 2
	{ '丙', 'bǐng' },   -- 3
	{ '丁', 'dīng' },   -- 4
	{ '戊', 'wù' },  -- 5
	{ '己', 'jǐ' },  -- 6
	{ '庚', 'gēng' },  -- 7
	{ '辛', 'xīn' },  -- 8
	{ '壬', 'rén' },  -- 9
	{ '癸', 'guǐ' }   -- 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 = {
	{ '子', 'zǐ' },           -- 1
	{ '丑', 'chǒu' },             -- 2
	{ '寅', 'yín' },       -- 3
	{ '卯', 'mǎo' },     -- 4
	{ '辰', 'chén' },     -- 5
	{ '巳', 'sì' },       -- 6
	{ '午', 'wǔ' },       -- 7
	{ '未', 'wèi' },         -- 8
	{ '申', 'shēn' },     -- 9
	{ '酉', 'yǒu' },   -- 10
	{ '戌', 'xū' },           -- 11
	{ '亥', 'hài' }            -- 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

local function kec(dayfrac,n)
	--Returns the current kè under the 120-kè system, used from 7CE to around 20CE?
	return math.floor(dayfrac/120)
end

local function shike(dayfrac)
	-- Returns the current shi and ke under the 100-ke system
	-- Each shi contains 
end

local function shikefen(dayfrac)
	-- Returns the current shi:ke:fen under the 100-ke, 60-fen system
end