Module:Date: Difference between revisions
NeonWabbit (talk | contribs) Created page with "-- Date functions for use by other modules. -- I18N and time zones are not supported. local MINUS = '−' -- Unicode U+2212 MINUS SIGN local floor = math.floor local Date, DateDiff, diffmt -- forward declarations local uniq = { 'unique identifier' } local function is_date(t) -- The system used to make a date read-only means there is no unique -- metatable that is conveniently accessible to check. return type(t) == 'table' and t._id == uniq end local function is_..." |
NeonWabbit (talk | contribs) No edit summary |
||
| Line 568: | Line 568: | ||
local function month_number(text) | local function month_number(text) | ||
return name_to_number(text, { | return name_to_number(text:gsub('%.', ''), { | ||
jan = 1, january = 1, | jan = 1, january = 1, | ||
feb = 2, february = 2, | feb = 2, february = 2, | ||
| Line 695: | Line 695: | ||
end | end | ||
-- | -- Cache the current date/time (UTC). | ||
-- | |||
-- Note that os.date() returns an empty object with optimized lazy getters for each field. | |||
-- Avoid current.min or current.sec in articles! https://phabricator.wikimedia.org/T416616 | |||
-- | |||
-- Beware that while os.date() uses 'min' and 'sec', our Date() uses 'minute' and 'second'. | |||
local current = os.date('!*t') | |||
local function extract_date(newdate, text) | local function extract_date(newdate, text) | ||
| Line 1,295: | Line 1,290: | ||
if argtype == 'currentdatetime' then | if argtype == 'currentdatetime' then | ||
newdate.hour = current.hour | newdate.hour = current.hour | ||
newdate.minute = current. | newdate.minute = current.min | ||
newdate.second = current. | newdate.second = current.sec | ||
newdate.hastime = true | newdate.hastime = true | ||
end | end | ||