Difference between revisions of "Template:Interval"

From blackwiki
Jump to navigation Jump to search
imported>MSGJ
(+doc)
imported>Anomie
m (Changed protection level for "Template:Interval": Syncing protection from formerly cascade-protected Template:ACEWatchlistNotice ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)))
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Interval/core
+
{{<includeonly>safesubst:</includeonly>#invoke:Interval|main}}<noinclude>
|n={{#ifeq:{{{format}}}|time
 
  |{{#time:U|{{{n|0}}}}}
 
  |{{{n|0}}}
 
}}
 
|1={{#ifeq:{{{format}}}|time
 
  |{{#time:U|{{{1|0}}}}}
 
  |{{{1|0}}}
 
}}
 
|2={{#ifeq:{{{format}}}|time
 
  |{{#time:U|{{{2|0}}}}}
 
  |{{{2|0}}}
 
}}
 
|3={{#ifeq:{{{format}}}|time
 
  |{{#time:U|{{{3|0}}}}}
 
  |{{{3|0}}}
 
}}
 
|4={{#ifeq:{{{format}}}|time
 
  |{{#time:U|{{{4|0}}}}}
 
  |{{{4|0}}}
 
}}
 
|rule={{#switch:{{{rule}}}
 
  |<=<
 
  |>=>
 
  |{{#ifeq:{{{rule}}}|≤|<=|>=}}
 
}}
 
}}<noinclude>
 
 
{{documentation}}
 
{{documentation}}
 +
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
 
</noinclude>
 
</noinclude>

Latest revision as of 01:11, 29 November 2018

0-1

Template documentation[view] [edit] [history] [purge]

Usage

This template determines which interval a given value lies in.

The intervals are defined by the unnamed parameters. The value to be determined is named parameter n.

format=time can also be passed to the template. If set, the intervals and value will be compared as times (and if n is not provided, it will evaluate as the current timestamp).

Examples

Passing 2, 4 and 6 as the unnamed parameters defines the following intervals:

  • -∞<x<2
  • 2≤x<4
  • 4≤x<6
  • 6≤x<∞

Then:

  • {{Interval|n=1|2|4|6}} gives 0-1 because 1 is in the interval between the 0th and 1st values.
  • {{Interval|n=4|2|4|6}} gives 2-3 because 4 is in the interval between the 2nd and 3rd values.
  • {{Interval|n=5|2|4|6}} gives 2-3 because 5 is in the interval between the 2nd and 3rd values.
  • {{Interval|n=6|2|4|6}} gives 3-4 because 6 is in the interval between the 3rd and 4th values.

Time

  • {{interval|14 October|24 October|29 October|7 December|format=time}} produces 4-5

See also