fbpx
วิกิพีเดีย

มอดูล:TimeAgo/testcases

-- Unit tests for [[Module:TimeAgo]]. Click talk page to run tests. local p = require('Module:UnitTests')  function p:test_main()  local lang = mw.language.getContentLanguage()   -- Calculate the time since/until the test dates here, since the expected output is dependent on the current time in most cases.  local currentTime = lang:formatDate( 'U' )  local jul09 = currentTime - lang:formatDate( 'U', '1 July 2009' )  local secondssincejul09 = math.floor( jul09 )  local minutessincejul09 = math.floor( jul09 / 60 )  local dayssincejul09 = math.floor( jul09 / 86400 )  local weekssincejul09 = math.floor( jul09 / 604800 )  local monthssincejul09 = math.floor( jul09 / 2678400 )  local yearssincejul09 = math.floor( jul09 / 31557600 )  local monthssincesep13 = math.floor( ( currentTime - lang:formatDate( 'U', '15 September 2013' ) ) / 2678400 )  local monthsuntiljul49 = math.floor( ( lang:formatDate ( 'U', '1 July 2049' ) - currentTime ) / 2678400 )  local yearsuntilaug57 = math.floor( ( lang:formatDate ( 'U', '4 August 2057' ) - currentTime ) / 31557600 )   self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|15 September 2013}}', monthssincesep13 .. ' months ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{CURRENTTIMESTAMP}}}}', '0 seconds ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|15 September 2013|purge=yes}}', monthssincesep13 .. ' months ago <span class="plainlinks">([//en.wikipedia.org/w/index.php?title=Module_talk:TimeAgo/testcases&action=purge purge])</span>')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{CURRENTTIMESTAMP}}|purge=yes}}', '0 seconds ago <span class="plainlinks">([//en.wikipedia.org/w/index.php?title=Module_talk:TimeAgo/testcases&action=purge purge])</span>')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009}}', yearssincejul09 .. ' years ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=minutes}}', minutessincejul09 .. ' minutes ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=days}}', dayssincejul09 .. ' days ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=weeks}}', weekssincejul09 .. ' weeks ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=months}}', monthssincejul09 .. ' months ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2049|magnitude=months}}', monthsuntiljul49 .. ' months\' time')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|Julio 1}}', '<strong class="error">Error: first parameter cannot be parsed as a date or time.</strong>')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=fruits}}', secondssincejul09 .. ' seconds ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main}}', '0 seconds ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=HoUrS}}', secondssincejul09 .. ' seconds ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|4 August 2057}}', yearsuntilaug57 .. ' years\' time')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|15 September 2013|ago=in the past}}', monthssincesep13 .. ' months in the past')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{CURRENTTIMESTAMP}}|min_magnitude=weeks}}', '0 weeks ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|15 September 2013|ago=}}', monthssincesep13 .. ' months')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=yes}}', 'twelve months ago') -- #time always gives one month too few  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=y}}', 'twelve months ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=y|spelloutmax=11}}', '12 months ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{#time: r | -12 months -14 days}}|magnitude=months|spellout=auto}}', '12 months ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|{{#time: r | -4 years -14 days}}|magnitude=years|spellout=auto}}', 'four years ago')  self:preprocess_equals('{{#invoke:TimeAgo/sandbox|main|July 1 2009|magnitude=weeks|spellout=yes}}', weekssincejul09 .. ' weeks ago') -- [[Module:NumberSpell]] can only spell numbers up to 100.  self:preprocess_equals_preprocess('{{#invoke:TimeAgo/sandbox|main|{{REVISIONTIMESTAMP}}|magnitude=days}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/86400)}} days ago')  self:preprocess_equals_preprocess('{{#invoke:TimeAgo/sandbox|main|{{REVISIONTIMESTAMP}}|magnitude=hours}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/3600)}} hours ago')  self:preprocess_equals_preprocess('{{#invoke:TimeAgo/sandbox|main|{{REVISIONTIMESTAMP}}|magnitude=minutes}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}})/60)}} minutes ago')  self:preprocess_equals_preprocess('{{#invoke:TimeAgo/sandbox|main|{{REVISIONTIMESTAMP}}|magnitude=seconds}}', '{{#expr:floor(({{LOCALTIMESTAMP}}-{{REVISIONTIMESTAMP}}))}} seconds ago') end  return p 

มอด, timeago, testcases, อหน, าช, ดทดสอบของมอด, มอด, timeago, ผลล, พธ, ของช, ดทดสอบ, unit, tests, module, timeago, click, talk, page, tests, local, require, module, unittests, function, test, main, local, lang, language, getcontentlanguage, calculate, time, si. nikhuxhnachudthdsxbkhxngmxdul mxdul TimeAgo phllphthkhxngchudthdsxb Unit tests for Module TimeAgo Click talk page to run tests local p require Module UnitTests function p test main local lang mw language getContentLanguage Calculate the time since until the test dates here since the expected output is dependent on the current time in most cases local currentTime lang formatDate U local jul09 currentTime lang formatDate U 1 July 2009 local secondssincejul09 math floor jul09 local minutessincejul09 math floor jul09 60 local dayssincejul09 math floor jul09 86400 local weekssincejul09 math floor jul09 604800 local monthssincejul09 math floor jul09 2678400 local yearssincejul09 math floor jul09 31557600 local monthssincesep13 math floor currentTime lang formatDate U 15 September 2013 2678400 local monthsuntiljul49 math floor lang formatDate U 1 July 2049 currentTime 2678400 local yearsuntilaug57 math floor lang formatDate U 4 August 2057 currentTime 31557600 self preprocess equals invoke TimeAgo sandbox main 15 September 2013 monthssincesep13 months ago self preprocess equals invoke TimeAgo sandbox main CURRENTTIMESTAMP 0 seconds ago self preprocess equals invoke TimeAgo sandbox main 15 September 2013 purge yes monthssincesep13 months ago lt span class plainlinks gt en wikipedia org w index php title Module talk TimeAgo testcases amp action purge purge lt span gt self preprocess equals invoke TimeAgo sandbox main CURRENTTIMESTAMP purge yes 0 seconds ago lt span class plainlinks gt en wikipedia org w index php title Module talk TimeAgo testcases amp action purge purge lt span gt self preprocess equals invoke TimeAgo sandbox main July 1 2009 yearssincejul09 years ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude minutes minutessincejul09 minutes ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude days dayssincejul09 days ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude weeks weekssincejul09 weeks ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude months monthssincejul09 months ago self preprocess equals invoke TimeAgo sandbox main July 1 2049 magnitude months monthsuntiljul49 months time self preprocess equals invoke TimeAgo sandbox main Julio 1 lt strong class error gt Error first parameter cannot be parsed as a date or time lt strong gt self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude fruits secondssincejul09 seconds ago self preprocess equals invoke TimeAgo sandbox main 0 seconds ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude HoUrS secondssincejul09 seconds ago self preprocess equals invoke TimeAgo sandbox main 4 August 2057 yearsuntilaug57 years time self preprocess equals invoke TimeAgo sandbox main 15 September 2013 ago in the past monthssincesep13 months in the past self preprocess equals invoke TimeAgo sandbox main CURRENTTIMESTAMP min magnitude weeks 0 weeks ago self preprocess equals invoke TimeAgo sandbox main 15 September 2013 ago monthssincesep13 months self preprocess equals invoke TimeAgo sandbox main time r 12 months 14 days magnitude months spellout yes twelve months ago time always gives one month too few self preprocess equals invoke TimeAgo sandbox main time r 12 months 14 days magnitude months spellout y twelve months ago self preprocess equals invoke TimeAgo sandbox main time r 12 months 14 days magnitude months spellout y spelloutmax 11 12 months ago self preprocess equals invoke TimeAgo sandbox main time r 12 months 14 days magnitude months spellout auto 12 months ago self preprocess equals invoke TimeAgo sandbox main time r 4 years 14 days magnitude years spellout auto four years ago self preprocess equals invoke TimeAgo sandbox main July 1 2009 magnitude weeks spellout yes weekssincejul09 weeks ago Module NumberSpell can only spell numbers up to 100 self preprocess equals preprocess invoke TimeAgo sandbox main REVISIONTIMESTAMP magnitude days expr floor LOCALTIMESTAMP REVISIONTIMESTAMP 86400 days ago self preprocess equals preprocess invoke TimeAgo sandbox main REVISIONTIMESTAMP magnitude hours expr floor LOCALTIMESTAMP REVISIONTIMESTAMP 3600 hours ago self preprocess equals preprocess invoke TimeAgo sandbox main REVISIONTIMESTAMP magnitude minutes expr floor LOCALTIMESTAMP REVISIONTIMESTAMP 60 minutes ago self preprocess equals preprocess invoke TimeAgo sandbox main REVISIONTIMESTAMP magnitude seconds expr floor LOCALTIMESTAMP REVISIONTIMESTAMP seconds ago end return p ekhathungcak https th wikipedia org w index php title mxdul TimeAgo testcases amp oldid 5301134, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม