Content deleted Content added
add to intro blurb |
add documentation for the date function, and update the number function |
||
Line 12:
* With no arguments, returns a real number in the range <math>[0,1)</math>.
* With one argument, returns an integer in the range <math>[1,m]</math>. <code>''m''</code> must be positive.
* With two arguments, returns an integer in the range <math>[m,n]</math>. <code>''m''</code> and <code>''n''</code> can be either positive or negative
'''Examples''' <small>({{purge|refresh|anchor=Number}})</small>
Line 21:
<small>The documentation for this function is partly taken from the [[mw:Extension:Scribunto/Lua reference manual#math.random|Scribunto Lua reference manual]], which is in turn based on the [http://www.lua.org/manual/5.1/index.html Lua 5.1 Reference Manual], available under the [[MIT License]].</small>
== Date ==
The <code>date</code> function outputs a random date.
{{#invoke:random|number|''timestamp1''|''timestamp2''|format=''date format''}}
* If no timestamp arguments are specified, the module outputs a random date in the current year.
* If <code>''timestamp1''</code> and <code>''timestamp2''</code> are specified, the module outputs a random date between the two timestamps. <code>''timestamp1''</code> must be earlier than <code>''timestamp2''</code>.
* If only <code>''timestamp1''</code>is specified, the module outputs a random date between the [[Unix epoch]] (1 Jan 1970) and the timestamp. <code>''timestamp1''</code> must not be earlier than 1 Jan 1970.
* Formatting can be specified with the {{para|format}} parameter. The default formatting is "hh:mm, DD Month YYYY (UTC)" (the same as the default Wikipedia timestamp).
* The timestamps and the {{para|format}} parameter accept values compatible with the [[mw:Help:Extension:ParserFunctions##time|#time parser function]]. Please see the #time documentation for the full range of possible input values and formatting options.
'''Examples''' <small>({{purge|refresh|anchor=Date}})</small>
* <code><nowiki>{{#invoke:random|date}}</nowiki></code> → {{#invoke:random|date}}
* <code><nowiki>{{#invoke:random|date|1 Jan 1980|31 Dec 1999}}</nowiki></code> → {{#invoke:random|date|1 Jan 1980|31 Dec 1999}}
* <code><nowiki>{{#invoke:random|date|1st January 1500|1st January 3000|format=g:i a, l d M Y}}</nowiki></code> → {{#invoke:random|date|1st January 1500|1st January 3000|format=g:i a, l d M Y}}
* <code><nowiki>{{#invoke:random|date|1970/06/01}}</nowiki></code> → {{#invoke:random|date|1970/06/01}}
== Item ==
|