Module:Sandbox/Hellknowz/Test: Difference between revisions

Content deleted Content added
okay, long weird code
fixes
Line 291:
-- Basically, any time '10am', '10:28', '10:28am', '10:28:27', '10:28:27am' can be followed by a date, which means 5 copies of 30+ lines (urgh)
-- Instead we will only check once, but using a different element index offset if needed, so date might start at element 4 or 5 or 6 etc.
-- Currently we only have '10', but if it turns out to be a time we will be checking if it's followed by a date
 
local wasTime = false -- by default we didn't find a valid time syntax, we have '10' and that's not a time by itself without 'am/pm' or further precision
Line 322 ⟶ 323:
if (wasTime) then -- '10am', '10:28', '10:28am', '10:28:27', '10:28:27am' (using just '10:28:27...' below)
-- Now we will try to append a date to the time
if (elements[3+i] == ELEMENT_WHITESPACE or elements[63+i] == ELEMENT_COMMA) then -- '10:28:27, '
if (elements[4+i] == ELEMENT_ONETWODIGITS) then -- '10:28:27, 3'
if (elements[5+i] == ELEMENT_WHITESPACE) then -- '10:28:27, 3 '
Line 328 ⟶ 329:
if (elements[7+i] == ELEMENT_WHITESPACE) then -- '10:28:27, 3 May '
if (elements[8+i] == ELEMENT_FOURDIGITS) then -- '10:28:27, 3 May 2013'
if (numberOfElements == 8+i) then return checkAndOutput(values[47+i], values[65+i], values[83+i], possibleHour, possibleMinute, possibleSecond) end
end
end
Line 336 ⟶ 337:
if (elements[4+i] == ELEMENT_WHITESPACE) then -- '10:28:27, May '
if (elements[5+i] == ELEMENT_ONETWODIGITS) then -- '10:28:27, May 3'
if (elements[6+i] == ELEMENT_COMMA or elements[106+i] == ELEMENT_WHITESPACE) then -- '10:28:27, May 3, '
if (elements[7+i] == ELEMENT_FOURDIGITS) then -- '10:28:27, May 3, 2013'
if (numberOfElements == 8+i) then return checkAndOutput(values[47+i], values[63+i], values[85+i], possibleHour, possibleMinute, possibleSecond) end
end
end
Line 348 ⟶ 349:
if (elements[6+i] == ELEMENT_DATESEPARATOR) then -- '10:28:27, 2013-05-'
if (elements[7+i] == ELEMENT_ONETWODIGITS) then -- '10:28:27, 2013-05-03'
if (numberOfElements == 8+i) then return checkAndOutput(values[43+i], values[65+i], values[87+i], possibleHour, possibleMinute, possibleSecond) end
end
end