Editing
Help:Magic words
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Formatting === <!-- Well gosh, with the source of the examples hidden, who can tell what you are inputting without looking here in the source? --> {| class="wikitable" ! {{Hl2}}| Usage ! {{Hl2}}| Input β Output ! {{Hl2}}| Description ! {{Hl2}}| Version |- |- | <code><nowiki>{{formatnum:</nowiki>''unformatted num''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{formatnum:</nowiki>''formatnum-formatted num''<nowiki>|R}}</nowiki></code> | <code><nowiki>{{formatnum:987654321.654321}}</nowiki></code> <br/> β {{formatnum:987654321.654321}} <br /> <code><nowiki>{{formatnum:987,654,321.654321|R}}</nowiki></code> <br/> β {{formatnum:987,654,321.654321|R}} <br /> <code><nowiki>{{formatnum:{{formatnum:987654321.654321}}|R}}</nowiki></code><br/> β 987654321.654321 (on any locale) <br /> <code><nowiki>{{formatnum:00001}}</nowiki></code> <br/> β {{formatnum:00001}} ---- Unsupported: <br /> <code><nowiki>{{formatnum:{{formatnum:987.654.321}}}}</nowiki></code> <br/> β 987 654 321 (e.g. with Italian locale) ---- Examples of wrong input (unreliable output), with or without <code>|R</code>: <br /> <code><nowiki>{{formatnum:987,654.321|R}}</nowiki></code> (the least broken) <br/> <code><nowiki>{{formatnum:987.654,321|R}}</nowiki></code> <br/> <code><nowiki>{{formatnum:987 654,321|R}}</nowiki></code> <br/> <code><nowiki>{{formatnum:987&nbsp;654,321|R}}</nowiki></code> | Takes an unformatted number (arab, no group separators and <code>.</code> as decimal separator) and outputs it in the localized digit script and formatted with decimal and decimal group separators, according to the wiki's default locale. <br /> The <code><nowiki>|</nowiki>R</code> parameter can be used to reverse the behaviour, for use in mathematical situations: it's reliable and should be used only to deformat numbers who are known to be formatted exactly as formatnum formats them with the wiki's locale. <br/> <small>{{warning}}Leading zeroes are not removed, you can use <nowiki>{{#expr:00001}}</nowiki> instead if you have [[Extension:ParserFunctions]] installed.</small> <br/> <small>{{warning}} If you don't input numbers in the exact format required, don't expect any reliable output, especially on non-English wikis.</small> ---- If you really need to format (according the wiki's locale) a number in unknown input format, you could try and use <code>formatnum</code> two times (but not if it can have a decimal group, or its separator will be eaten or the number won't be formatted). | 1.7+ <br />{{mediawiki|rev:32012|1.13+}} |- | <code><nowiki>{{#dateformat:</nowiki>''date''<nowiki>}} {{#formatdate:</nowiki>''date''<nowiki>}} {{#dateformat:</nowiki>''date''{{!}}''format''<nowiki>}} {{#formatdate:</nowiki>''date''{{!}}''format''<nowiki>}}</nowiki></code> | <code><nowiki>{{#dateformat:25 deC 2009|ymd}}</nowiki></code> <br/> β {{#dateformat:25 deC 2009|ymd}} (your pref), 2009 DeC 25 (default) <br/> <code><nowiki>{{#formatdate:dec 25,2009|dmy}}</nowiki></code> <br/> β {{#formatdate:dec 25,2009|dmy}} (your pref), 25 Dec 2009 (default) <br/> <code><nowiki>{{#dateformat:2009-12-25|mdy}}</nowiki></code> <br/> β {{#dateformat:2009-12-25|mdy}} (your pref), December 25, 2009 (default) <br/> <code><nowiki>{{#formatdate:2009 dec 25|ISO 8601}}</nowiki></code> <br/> β {{#formatdate:2009 dec 25|ISO 8601}} (your pref), 2009-12-25 (default) <br/> <code><nowiki>{{#dateformat:25 decEmber|mdy}}</nowiki></code> <br/> β {{#dateformat:25 decEmber|mdy}} (your pref), DecEmber 25 (default) <br/> Note: In the example hereinbefore, "your pref" refers to your date preference on the current MediaWiki wiki only. | Formats an unlinked date based on user "date format" preference, and adds metadata tagging it as a formatted date. For logged-out users and those who have not set a date format in their preferences, dates can be given a default: <code>mdy</code>, <code>dmy</code>, <code>ymd</code>, <code>ISO 8601</code> (all case sensitive). If only the month and day are given, only <code>mdy</code> and <code>dmy</code> are valid. If a format is not specified or is invalid, the input format is used as a default. If the supplied date is not recognized as a valid date (specifically, if it contains any metadata such as from a nested use of these or similar templates), it is rendered unchanged, and no (additional) metadata is generated. <br/><small>{{warning}}Although the ISOΒ 8601 standard requires that dates be in the Gregorian calendar, the ISO parameter in this function will still format dates that fall outside the usual Gregorian range (e.g. dates prior to 1583). Also, the magic word cannot properly convert between negative years (used with ISOΒ 8601) and years BC or years BCE (used in general writing).</small> | {{mediawiki|rev:48249|1.15+}} |- | <code><nowiki>{{lc:</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{lc:DATA CENTER}}</nowiki></code> β {{lc:DATA CENTER}} | The lowercase input. | 1.5+ |- | <code><nowiki>{{lcfirst:</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{lcfirst:DATA center}}</nowiki></code> β {{lcfirst:DATA center}} | The input with the <u>very first</u> character lowercase. | 1.5+ |- | <code><nowiki>{{uc:</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{uc:text transform}}</nowiki></code> β {{uc:text transform}} | The uppercase input. | 1.5+ |- | <code><nowiki>{{ucfirst:</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{ucfirst:text TRANSFORM}}</nowiki></code> β {{ucfirst:text TRANSFORM}} | The input with the <u>very first</u> character uppercase. | 1.5+ |- | <code><nowiki>{{padleft:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padleft:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padleft:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{padleft:xyz|5}}</nowiki></code> β {{padleft:xyz|5}} <br /> <code><nowiki>{{padleft:xyz|5|_}}</nowiki></code> β {{padleft:xyz|5|_}} <code><nowiki>{{padleft:xyz|5|abc}}</nowiki></code> β {{padleft:xyz|5|abc}} <code><nowiki>{{padleft:xyz|2}}</nowiki></code> β {{padleft:xyz|2}} <br /> <code><nowiki>{{padleft:|1|xyz}}</nowiki></code> β {{padleft:|1|xyz}} (first character of the string) <br /> | Inserts a string of padding characters (character chosen in third parameter; default "0") of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. <code><nowiki>{{padleft:44|3|0}}</nowiki></code> produces {{padleft:44|3}}. The padding string may be truncated if its length does not evenly divide the required number of characters. <br />'''{{mediawiki|bugzilla:16852|Bug}} (fixed in {{mediawiki|rev:45734|r45734}}):''' multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters. | 1.8+ |- | <code><nowiki>{{padright:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''string''<nowiki>}}</nowiki></code> | <code><nowiki>{{padright:xyz|5}}</nowiki></code> β {{padright:xyz|5}} <br /> <code><nowiki>{{padright:xyz|5|_}}</nowiki></code> β {{padright:xyz|5|_}} <code><nowiki>{{padright:xyz|5|abc}}</nowiki></code> β {{padright:xyz|5|abc}} <code><nowiki>{{padright:xyz|2}}</nowiki></code> β {{padright:xyz|2}} <br /> <code><nowiki>{{padright:|1|xyz}}</nowiki></code> β {{padright:|1|xyz}} <br /> | Identical to padleft, but adds padding characters to the right side. | |} '''See also:''' [[Extension:StringFunctions]].
Summary:
Please note that all contributions to Fanra's EverQuest Wiki are considered to be released under the Creative Commons Attribution Share Alike (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Help page
Discussion
English
Views
Read
Edit source
View history
More
Search
Main Menu
Main page
Sections
Classes and Races
Spells, Songs, Disciplines, and AAs
Items
Zones
NPCs
Quests
Raids
Tradeskills
User Interface
Tips and Guides
EQ Links
Wiki
Recent changes
Advanced search
Random page
Help
Contact Fanra
Tools
What links here
Related changes
Upload file
Special pages
Page information