Module:time/testcases
Jump to navigation
Jump to search
- The following documentation is located at Module:time/testcases/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • tested module • sandbox
65/107 successes
input | occurrences | output | expected | error |
---|---|---|---|---|
January 1911 |
1065 | 1911 January 1 |
1911 January |
|
1843-06 |
368 | 1843 June 1 |
1843 June |
|
{{J2G|30 August 1585}} |
39 | ??? |
Module:time:12: Timestamp '{{J2G|30 August 1585}}' could not be parsed; see the documentation for the #time parser function).
| |
11 Sep, 2004 |
30 | 2004 September 11 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
1993 April |
25 | 1993 April 1 |
1993 April |
|
2017, 14 November |
14 | 2024 November 14 |
2017 November 14 |
|
7 January, 1837 |
12 | 1837 January 7 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
February |
10 | 2024 February 26 |
??? |
|
September 30 |
8 | 2024 September 30 |
??? |
|
February 11th, 1839 |
8 | 1839 February 11 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
2017, February 16 |
7 | 2024 February 16 |
2017 February 16 |
|
November, 2018 |
6 | 2018 November |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
2017, 2 March |
5 | 2024 March 2 |
2017 March 2 |
|
March 3rd, 2020 |
5 | 2020 March 3 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
February 24,2016 2016 |
5 | 2016 February 24 |
??? |
|
{{J2G|2 January 1579}} |
5 | ??? |
Module:time:12: Timestamp '{{J2G|2 January 1579}}' could not be parsed; see the documentation for the #time parser function).
| |
2018, January 5 |
3 | 2024 January 5 |
2018 January 5 |
|
15 Jul 2010 2010 |
2 | 2010 July 15 |
??? |
|
20 December1806 |
2 | 1806 December 20 |
??? |
|
17.03.19 |
2 | 2024 November 26 |
??? |
|
n.d. |
2 | 2024 November 26 |
??? |
|
October 2 |
2 | 2024 October 2 |
??? |
|
September 29, 1905 1905 |
2 | 1905 September 29 |
??? |
|
9 September 9 2005 |
1 | 2009 September 9 |
??? |
|
1 March 1, 1988 |
1 | 1988 March 1 |
??? |
|
1 September1870 |
1 | 1870 September 1 |
??? |
|
4/11/03 2003 |
1 | 2003 April 11 |
??? |
|
05 SEPTEMBER, 2018 |
1 | 2018 September 5 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
27 January 27 2010 |
1 | 2027 January 27 |
??? |
|
25 February 1996. |
1 | 1996 February 25 |
??? |
|
05-2-27 |
1 | 2005 February 27 |
??? |
|
30.6.2011-06-30 |
1 | 2011 June 30 |
??? |
|
11/19, 2015 |
1 | 2024 November 19 |
November 19 |
|
2011, October 7th |
1 | 2024 October 7 |
2011 October 7 |
|
1974-5 |
1 | 1974 May 1 |
1974 May |
|
2005...2011 |
1 | 2011 November 26 |
??? |
|
March 23, 1658-9 |
1 | 1658 March 23 |
1658-9 March 23 |
|
February 2010 2010 |
1 | 2010 February 1 |
??? |
|
September 2003, 2003 |
1 | 2003 September 1 |
??? |
|
Wed, 28 Feb 2001 2001 |
1 | 2001 February 28 |
??? |
|
Saturday, December 7th, 2019 |
1 | 2019 December 7 |
Module:time:46: |date= parameter should contain a full date: year, month, day of month. Use |month= and |year= parameters for month and year.
| |
January20, 2010 |
1 | 2010 January 20 |
??? |
local export = {}
local schemata
local function code_tag(text, class)
if class then
return '<code class="' .. class .. '">' .. mw.text.nowiki(text) .. '</code>'
else
return "<code>" .. mw.text.nowiki(text) .. "</code>"
end
end
local function iterate_tsv(tsv)
local rows = tsv:gmatch "[^\n]+"
return function()
local row = rows()
if row then
local columns = {}
local prev_pos = 1
for start_pos, column, tab, end_pos in row:gmatch "()([^\t]+)(\t?)()" do
if not (start_pos == prev_pos and (tab == "") == (end_pos == #row + 1)) then
error("incorrect format in " .. row)
end
table.insert(columns, column)
prev_pos = end_pos
end
return unpack(columns)
end
end
end
local remove_links = require "Module:links".remove_links
function export.test_date_formatting(frame)
local module_name = frame.args.module
local quote_impl = require(module_name and "Module:" .. module_name or "Module:time").quote_impl
local function format_date(date)
return quote_impl { date = date }
end
local output = require "Module:array"()
output:insert [[
{| class="wikitable"
! input !! occurrences !! output !! expected !! error
]]
local counts = { [true] = 0, [false] = 0 }
for schema, count, date, expected in iterate_tsv(schemata) do
count = tonumber(count)
if not schema then
error("Line didn't match pattern: " .. line)
end
local ok, formatted = pcall(function() return format_date(date):gsub("'''", "") end)
local success = ok and formatted == expected
counts[success] = counts[success] + 1
if ok then
if formatted ~= expected then
output:insert "|-"
output:insert("| " .. code_tag(date) .. " || " .. count .. " || "
.. code_tag(formatted) .. " || " .. code_tag(expected) .. " ||")
end
else
output:insert "|-"
output:insert("| " .. code_tag(date) .. " || " .. count
.. " || || " .. code_tag(expected) .. " || "
.. code_tag(remove_links(formatted), "error"))
end
end
output:insert "|}"
output:insert(1, counts[true] .. "/" .. (counts[true] + counts[false]) .. " successes")
return output:concat "\n"
end
schemata = [[
<u><l> <d2>, <d4> 19297 September 14, 2014 2014 September 14
<u><l> <d1>, <d4> 8324 March 9, 2008 2008 March 9
<d4>-<d2>-<d2> 6293 1997-07-14 1997 July 14
<d2> <u><l> <d4> 4526 15 October 2002 2002 October 15
<u><l> <d2> <d4> 2866 Oct 18 2011 2011 October 18
<d1> <u><l> <d4> 1914 6 March 1992 1992 March 6
<u><l> <d1> <d4> 1252 Apr 7 2003 2003 April 7
<u><l> <d4> 1065 January 1911 1911 January
<d4>-<d2> 368 1843-06 1843 June
<d4> <u><l> <d2> 206 1939 December 15 1939 December 15
<d4>-<d1>-<d2> 190 2018-4-22 2018 April 22
<d2>-<d2>-<d4> 180 10-05-2003 2003 May 10
<u><l>. <d2>, <d4> 179 Aug. 13, 2015 2015 August 13
<d4> <u><l> <d1> 173 2020 January 2 2020 January 2
<u><l>. <d1>, <d4> 102 Dec. 2, 2003 2003 December 2
<d1>/<d2>/<d4> 84 7/30/2015 2015 July 30
<d2>/<d2>/<d4> 80 04/04/2002 2002 April 4
<d4>-<d1>-<d1> 54 2020-3-2 2020 March 2
{{<u><d1><u>|<d2> <u><l> <d4>}} 39 {{J2G|30 August 1585}} ???
<d4>/<d2>/<d2> 32 2006/01/17 2006 January 17
<d2> <u><l>, <d4> 30 11 Sep, 2004 2004 September 11
<d1>/<d1>/<d4> 28 7/7/2015 2015 July 7
<d4> <u><l> 25 1993 April 1993 April
<d1>/<d2>/<d2> 19 3/24/15 2015 March 24
<d4>, <d2> <u><l> 14 2017, 14 November 2017 November 14
<d2>/<d2>/<d2> 13 07/23/17 2017 July 23
<d1> <u><l>, <d4> 12 7 January, 1837 1837 January 7
<d2>/<d1>/<d4> 12 10/4/2014 2014 October 4
<d4>-<d2>-<d1> 12 1707-04-7 1707 April 7
<d2> <u><l> <d2> 11 12 May 92 1992 May 12
<u><l> 10 February ???
<d2>.<d2>.<d4> 9 21.10.2014 2014 October 21
<d4>-<d2>-<d2><u><d2>:<d2>:<d2> 8 2002-12-18T04:19:52 2002 December 18
<u> <d2>, <d4> 8 APR 17, 2015 2015 April 17
<u><l> <d2> 8 September 30 ???
<u><l> <d2><l>, <d4> 8 February 11th, 1839 1839 February 11
<d1>/<d1>/<d2> 7 4/1/15 2015 April 1
<d2>-<d1>-<d4> 7 14-4-2017 2017 April 14
<d4>, <u><l> <d2> 7 2017, February 16 2017 February 16
<d2>-<d2>-<d2> 6 08-12-31 2008 December 31
<d4>/<d1>/<d2> 6 1995/8/21 1995 August 21
<u><l>, <d4> 6 November, 2018 2018 November
<d1>-<d1>-<d4> 5 1-5-1840 1840 May 1
<d2>-<u><l>-<d2> 5 15-Jul-83 1983 July 15
<d4>, <d1> <u><l> 5 2017, 2 March 2017 March 2
<d4>-<d2>-<d2><u><d2>:<d2> 5 1992-12-08T22:34 1992 December 8
<u><l> <d1>,<d4> 5 August 8,1864 1864 August 8
<u><l> <d1><l>, <d4> 5 March 3rd, 2020 2020 March 3
<u><l> <d2>,<d4> 5 February 24,2016 2016 ???
{{<u><d1><u>|<d1> <u><l> <d4>}} 5 {{J2G|2 January 1579}} ???
<d2> <l> <d4> 4 14 august 2017 2017 August 14
<d1>-<d2>-<d4> 3 9-11-2017 2017 November 9
<d1>-<u><l>-<d2> 3 8-Mar-87 1987 March 8
<d2>.<d1>.<d4> 3 23.1.2020 2020 January 23
<d2>/<d1>/<d2> 3 01/6/17 2017 January 6
<d4>, <u><l> <d1> 3 2018, January 5 2018 January 5
<u> <d1>, <d4> 3 APR 5, 2019 2019 April 5
<u><l> <d2>. <d4> 3 May 27. 2010 2010 May 27
<d1> <l> <d4> 2 7 march 2018 2018 March 7
<d1> <u><l> <d2> 2 7 Jun 90 1990 June 7
<d1>. <u><l> <d4> 2 8. April 2020 2020 April 8
<d2> <u><l> <d4> <d4> 2 15 Jul 2010 2010 ???
<d2> <u><l><d4> 2 20 December1806 ???
<d2>. <u><l> <d4> 2 27. November 1844 1844 November 27
<d2>.<d2>.<d2> 2 17.03.19 ???
<d2><l> <u><l> <d4> 2 14th October 2018 2018 October 14
<d4>-<u><l>-<d2> 2 2005-May-31 2005 May 31
<l>.<l>. 2 n.d. ???
<u><l> <d1> 2 October 2 ???
<u><l> <d2>, <d4> <d4> 2 September 29, 1905 1905 ???
<u><l> <d2><l> <d4> 2 February 15th 1999 1999 February 15
<u><l>, <d2> <u><l> <d4> <d2>:<d2>:<d2> +<d4> 2 Mon, 23 Feb 2004 11:26:07 +0100 2004 February 23
<d1> <u><l> <d1> <d4> 1 9 September 9 2005 ???
<d1> <u><l> <d1>, <d4> 1 1 March 1, 1988 ???
<d1> <u><l><d4> 1 1 September1870 ???
<d1>. <l> <d4> 1 3. october 2015 2015 October 3
<d1>/<d2>/<d2> <d4> 1 4/11/03 2003 ???
<d2> <l>. <d4> 1 17 jan. 2014 2014 January 17
<d2> <u>, <d4> 1 05 SEPTEMBER, 2018 2018 September 5
<d2> <u><l> <d2> <d4> 1 27 January 27 2010 ???
<d2> <u><l> <d4>. 1 25 February 1996. ???
<d2>-<d1>-<d2> 1 05-2-27 ???
<d2>. <l> <d4> 1 02. october 2018 2018 October 2
<d2>.<d1>.<d4>-<d2>-<d2> 1 30.6.2011-06-30 ???
<d2>/<d2>, <d4> 1 11/19, 2015 November 19
<d4>, <u><l> <d1><l> 1 2011, October 7th 2011 October 7
<d4>-<d1> 1 1974-5 1974 May
<d4>-<d2>-<d2><u><d2>:<d2>:<d2>+<d4> 1 2008-09-25T20:53:38+0200 2008 September 25
<d4>...<d4> 1 2005...2011 ???
<l> <d1>, <d4> 1 october 7, 2013 2013 October 7
<l> <d2>, <d4> 1 january 26, 2018 2018 January 26
<u> <d2> <u> <d4> 1 SATURDAY 02 MARCH 2019 2019 March 2
<u><l> <d1>, <d4>. 1 March 4, 2016. 2016 March 4
<u><l> <d1>. <d4> 1 February 7. 2008 2008 February 7
<u><l> <d1><l> <d4> 1 June 4th 2009 2009 June 4
<u><l> <d2>, <d4>-<d1> 1 March 23, 1658-9 1658-9 March 23
<u><l> <d2>, <d4>. 1 Dec 16, 2015. 2015 December 16
<u><l> <d4> <d4> 1 February 2010 2010 ???
<u><l> <d4>, <d4> 1 September 2003, 2003 ???
<u><l>, <d2> <u><l> <d4> <d2>:<d2>:<d2> <u> 1 Sat, 22 Sep 2001 22:12:03 GMT 2001 September 22
<u><l>, <d2> <u><l> <d4> <d4> 1 Wed, 28 Feb 2001 2001 ???
<u><l>, <d2>-<u><l>-<d2> 1 Wed, 14-Nov-84 1984 November 14
<u><l>, <u><l> <d1><l>, <d4> 1 Saturday, December 7th, 2019 2019 December 7
<u><l>. <d2> <d4> 1 Dec. 16 2014 2014 December 16
<u><l>.<d2>, <d4> 1 Nov.12, 1996 1996 November 12
<u><l><d2>, <d4> 1 January20, 2010 ???
<u><l><u> <d2>, <d4> 1 SeptembeR 24, 2011 2011 September 24]]
return export