Editing
Module
:
DTZ
Jump to navigation
Jump to search
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!
--[[ Format date/times with time zones. Input can be specified using the following subset of ISO 8601: YYYY-MM-DDTHH:MMZ (UTC) YYYY-MM-DDTHH:MM+HH (hours ahead of UTC) YYYY-MM-DDTHH:MM+HH:MM (hours and minutes ahead of UTC) YYYY-MM-DDTHH:MM-HH (hours behind of UTC) YYYY-MM-DDTHH:MM-HH:MM (hours and minutes behind of UTC) and similar strings with seconds included in the time: YYYY-MM-DDTHH:MM:SSZ YYYY-MM-DDTHH:MM:SS+HH YYYY-MM-DDTHH:MM:SS+HH:MM YYYY-MM-DDTHH:MM:SS-HH YYYY-MM-DDTHH:MM:SS-HH:MM ]] local p = {} local Date = require('Module:DateI18n-585816189') local errorcat = "[[Category:Incorrect use of DTZ]]" local function format(year, month, day, hour, minute, second, tzhour, tzmin, lang) local result = Date._Date({year, month, day, hour, minute, second, tzhour, tzmin}, lang) if result == '' then return "invalid values in date/time" .. errorcat end return result end function p.DTZ(frame) local input = mw.text.trim(frame.args[1]) local lang = frame:callParserFunction("int", "lang") -- user's language -- local all, year, month, day, hour, minute, second = input:match("^((%d%d%d%d)-(%d%d)-(%d%d)T(%d%d):(%d%d):(%d%d))") if all == nil then all, year, month, day, hour, minute = input:match("^((%d%d%d%d)-(%d%d)-(%d%d)T(%d%d):(%d%d))") if all == nil then return "invalid date/time format" .. errorcat end end local tzhour, tzmin local rest = input:sub(all:len()+1) if rest == '' then return "missing timezone" .. errorcat end if rest:len() == 1 and rest:sub(1,1) == 'Z' then return format(year, month, day, hour, minute, second, '0', '', lang) end local tzsign tzsign, tzhour, tzmin = rest:match("^([+-])(%d%d):(%d%d)$") if tzsign == nil then tzsign, tzhour = rest:match("^([+-])(%d%d)$") if tzsign == nil then return "invalid timezone" .. errorcat end tzmin = '00' -- work around a glitch in Module:Date -- end if tzsign == '-' then tzhour = -1 * tzhour end return format(year, month, day, hour, minute, second, tzhour, tzmin, lang) end return p
Summary:
Please note that all contributions to Islamical Commons may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
commons:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Page included on this page:
Module:DTZ/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
associated-pages
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
welcome
Community portal
village pump
participate
Upload file
Recent changes
latestfiles
Random File
contact
Special pages
Tools
What links here
Related changes
Upload file
Page information