Module:TimedeltaUtil

local util_args = require("Module:ArgsUtil") local util_time = require("Module:TimeUtil") local util_vars = require("Module:VarsUtil")

local Seconds = require('Module:TimedeltaAbstract'):extends local Display = require('Module:TimedeltaAbstract'):extends

local SECONDS_PER_DAY = 24 * 60 * 60 Display.outputUnknown = '??' Seconds.outputUnknown = -1 Display.fuzzyPrefix = '≈' Seconds.fuzzyPrefix = '' Display.lessThanOneYear = '<1y' Seconds.lessThanOneYear = 365 * SECONDS_PER_DAY Display.lessThan = '≤' Seconds.lessThan = '' Display.clarifyApprox = '??' Seconds.clarifyApprox = ''

function Display:lessThanOneMonth(days) return '<1m' end function Seconds:lessThanOneMonth(days) return days * SECONDS_PER_DAY end

function Seconds:approxDurationExact(sDate, eDate) return os.difftime(util_time.unix(eDate), util_time.unix(sDate)) end

function Seconds:addFuzzyPrefixIffNeeded(ret) return ret end

local p = {}

function p.test(frame) local args = util_args.merge s = args.s	e = args.e	return (' %s  %s  %s  %s '):format(		args.s,		args.e,		Display:main(args.s, args.e, util_args.castAsBool(args.fuzzy)),		Seconds:main(args.s, args.e, util_args.castAsBool(args.fuzzy))	) end

function p.approxDurationDisplay(s, e, fuzzy) return Display:main(s, e, fuzzy) end

function p.approxDurationSeconds(s, e, fuzzy) return Seconds:main(s, e, fuzzy) end

function p.approxDurationDays(s, e, fuzzy) return Seconds:main(s, e, fuzzy) / SECONDS_PER_DAY end

return p