Template talk:0expr

Documentation

edit

{{0expr}} adds a leading zero to non-negative results < 10 for date calculations.

Usage

edit
{{0expr|expression}} - returns result as is, or 0result for 0 <= result < 10.
{{0expr|1=expression}} - ditto for expressions containing equal signs.
Updates:
  1. The code was simplified for better support of optional substitution (= no more parameter defaults), hence empty expressions are not more supported.
  2. Decimal fractions are now kept as is (1.25 results in 01.25), this can be useful for the seconds in timestamps hhmmss.nnn, see ISO 8601.

Example

edit
Code Result
{{0expr|-1}} -1
{{0expr|123/100}} 01.23
{{0expr|1+9}} 10
{{0expr|not 10}} 00
{{0expr|1=(7<=8)*9}} 09
{{0expr|(7<=8)*9|2+3}} 05

The last example shows that expressions containing "=", "<=", or ">=" won't work directly.

See also

edit

Discussion

edit

Add issues below as you see fit, sign with ~~~~

Return to "0expr" page.