Jump to content
Wikimedia Meta-Wiki

Module:Unsigned

From Meta, a Wikimedia project coordination wiki
Module documentation
You might want to create a documentation page for this Scribunto module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
 localp={}

 -- There's probably a way to use strptime or some other more sophisticated way, but you're not supposed to be using a non-timestamp as input anyway.

 localfunctionendswith(String,End)
 returnEnd==''orstring.sub(String,-string.len(End))==End
 end

 localfunctiontrim(s)
 returns:gsub("^%s+",""):gsub("%s+$",""):gsub("226円128円142円","")
 end

 localfunctionaddUtcToStringIfItDoesNotEndWithUtc(s)
 ifs==""orendswith(s,"~~~~")thenreturnsend
 ifnotendswith(s,"(UTC)")then
 returns.." (UTC)"
 end
 returns
 end

 localfunction_main(args)
 localhopefullyTimestamp=args[1]oros.date('%H:%M, %d %B %Y (%Z)')
 returnaddUtcToStringIfItDoesNotEndWithUtc(trim(hopefullyTimestamp))
 end

 functionp.main(frame)
 localargs
 iftype(frame.args)=='table'then
 -- We're being called via #invoke. The args are passed through to the module
 -- from the template page, so use the args that were passed into the template.
 args=frame.args
 else
 -- We're being called from another module or from the debug console, so assume
 -- the args are passed in directly.
 args=frame
 end
 return_main(args)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /