Rabbitty's Sandbox Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Recent Blog Posts
The Rabbittian Library of Code
File Wing
Colo(u)rs Wing
div Wing
Background Hall
Text Hall
font Wing
If Statements Wing
Text Tags Wing
Imports Wing
Quotes
Fucking and Something and Love
Exultant
Agony
Essays
Not-Quite-Essays
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Rabbitty's Sandbox Wiki
98
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Recent Blog Posts
The Rabbittian Library of Code
File Wing
Colo(u)rs Wing
div Wing
Background Hall
Text Hall
font Wing
If Statements Wing
Text Tags Wing
Imports Wing
Quotes
Fucking and Something and Love
Exultant
Agony
Essays
Not-Quite-Essays
Editing
Module:Datecalc
Back to page
Edit source
View history
Talk (5)
Edit Page
Module:Datecalc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <pre>Description: Wrapper/invocable for [[Module:Date]] -- Syntax : based on http://tieske.github.io/date/ Use YYYY-MM-DD if possible -- {{#invoke:Datecalc|main|funcname|date|arg1|arg2...}} -- Example: -- {{#invoke:Datecalc|main|diff|2013/12/10|2013/12/11}},{{#invoke:Datecalc|main|adddays|2013/12/10|5}} local p ={} local getArgs = require("Dev:Arguments").getArgs local gDate = require("Dev:Date") --% Entry point --@ frame (table) Scribunto frame --: (string) Results of date calculation function p.main(frame) local args = getArgs(frame) return p._main(args) end --% Entry point --@ args (table) Template arguments --: (string) Results of date calculation function p._main(args) local currentDate = os.date("%Y/%m/%d") local func = args[1] local tDateFuncs = {diff = 1, epoch = 1, isleapyear = 1} if not func then return end if tDateFuncs[func] then local arg2 = args[2] local arg3 = args[3] or currentDate if func =="diff" and arg2 and arg3 then return gDate[func](arg2, arg3):spandays() end return gDate[func](arg2) else currentDate = args[2] or currentDate local objDate = gDate(currentDate) local dateParams = {} if args[1] or args[2] then --Excludes function, date, leaves rest of parameters for i,v in ipairs(args) do if i>2 then table.insert(dateParams,args[i]) end end end return objDate[func](objDate, unpack(dateParams)) end end return p
Summary:
Please note that all contributions to the Rabbitty's Sandbox Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab