Changes

Jump to navigation Jump to search
Imported page
<includeonly><!--
-->{{#if: {{{1|}}}<!--
-->|<!--
# parameter, exists and is not empty
-->{{#if: {{#invoke:String|match|{{{1|}}}|^ *%d+ *$|1|1|false|}}<!--
-->|<!--
# it's all digits
-->{{Year category name/AD year|{{{1|}}}}}<!--
-->|<!--
# it's not all digits
# First test for "YYY BC"/"YYYBC"
-->{{#if: {{#invoke:String|match|{{{1|}}}|^ *%d+ *BC *$|1|1|false|}}<!--
-->|<!--
# it's YYY BC, which is the canonical format for a BC year, or "YYYBC" (which needs an extra space)
# Either way, just extract the number and append " BC"
-->{{#invoke:String|replace|{{{1|}}}|^%D*(%d+)%D*$|%1 BC|1|false}}<!--
-->|<!--
# it's not "YYY BC"/"YYYBC"
# So test for "BC YYY"/"BCYYY" (e.g. BC 185)
-->{{#if: {{#invoke:String|match|{{{1|}}}|^ *BC *%d+ *$|1|1|false|}}<!--
-->|<!--
# It's "BC YYY" or "BCYYY", so convert it to YYY BC
-->{{#invoke:String|replace|{{{1|}}}|^ *(BC) *(%d+) *$|%2 %1|1|false}}<!--
-->|<!--
# It's not "BC YYY"/"BCYYY", so test for either "AD YYY"/"ADYYY" or "YYY AD"/"YYYAD"
-->{{#ifexpr: {{#invoke:String|find|{{{1|}}}|^ *AD *%d+ *$|1|false}} +<!--
-->{{#invoke:String|find|{{{1|}}}|^ *%d+ *AD *$|1|false}}<!--
--> > 0<!--
-->|<!--
# It's either "AD YYY"/"ADYYY" or "YYY AD"/"YYYAD"
-->{{Year category name/AD year|{{#invoke:String|replace|{{{1|}}}|^%D*(%d+)%D*$|%1|1|false}}}}<!--
-->|<!--
# It's NOT either "AD YYY"/"ADYYY" or "YYY AD"/"YYYAD"
# So test for a negative number used to represent a BC year, e.g. "-73" or "-506"
-->{{#if: {{#invoke:String|match|{{{1|}}}|^ *%-(%d+) *$|1|1|false|}}<!--
-->|<!--
# We have a negative number
# So output its absolute value followed by "BC"
# e.g. for "-472" we output "472 BC"
-->{{#invoke:String|replace|{{{1|}}}|^%D*(%d+)%D*$|%1 BC|1|false}}<!--
-->|<!--
# Not a negative number
# We have tried all possibilities, so this is some invalid input
# Therefore output nothing
-->}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->|<!--
# missing or empty parameter, so return nothing
-->}}</includeonly><!--
--><noinclude><!--
-->{{Documentation}}<!--
--><noinclude>
Bureaucrats, Check users, editor, emailconfirmed, Interface administrators, reviewer, smwadministrator, smwcurator, smweditor, Suppressors, Administrators
12,798

edits

Navigation menu