User:Rich Farmbrough/ISBN
ISBN {{#ifexpr:{{CURRENTYEAR}}>2006
|978-{{{10}}}-
|{{{10}}}-
}}{{#ifexpr:{{CURRENTYEAR}}>2006
|{{#expr:({{{1}}}*3+ {{{2}}}*1+ {{{3}}}*3+ {{{4}}}*1+ {{{5}}}*3+ {{{6}}}*1+ {{{7}}}*3+ {{{8}}}*1+ {{{9}}}*3) mod 9}}
|{{#ifeq: ({{{1}}}*1+ {{{2}}}*2+ {{{3}}}*3+ {{{4}}}*4+ {{{5}}}*5+ {{{6}}}*6+ {{{7}}}*7+ {{{8}}}*8+ {{{9}}}*9) mod 11|10
|X
|{{#expr:({{{1}}}*1+ {{{2}}}*2+ {{{3}}}*3+ {{{4}}}*4+ {{{5}}}*5+ {{{6}}}*6+ {{{7}}}*7+ {{{8}}}*8+ {{{9}}}*9) mod 11}}
}}}}
This is called thusly,
a. Suppose we have a 10 digit ISBN 0-593-01518-5
b. Suppose we have a 13 digit ISBN 978-0-593-01518-4
Up to 1 January 2007 this will display
ISBN {{#ifexpr:{{CURRENTYEAR}}<2005
|978-0-593-01518-
|0-593-01518-
}}{{#ifexpr:{{CURRENTYEAR}}<2005
|{{#expr:(0*3+ 5*1+ 9*3+ 3*1+ 0*3+ 1*1+ 5*3+ 1*1+ 8*3) mod 9}}
|{{#ifeq: (0*1+ 5*2+ 9*3+ 3*4+ 0*5+ 1*6+ 5*7+ 1*8+ 8*9) mod 11|10
|X
|{{#expr:(0*1+ 5*2+ 9*3+ 3*4+ 0*5+ 1*6+ 5*7+ 1*8+ 8*9) mod 11}}
}}}}
Afterwards as
ISBN {{#ifexpr:{{CURRENTYEAR}}>2005
|978-0-593-01518-
|0-593-01518-
}}{{#ifexpr:{{CURRENTYEAR}}>2005
|{{#expr:(0*3+ 5*1+ 9*3+ 3*1+ 0*3+ 1*1+ 5*3+ 1*1+ 8*3) mod 9}}
|{{#ifeq: (0*1+ 5*2+ 9*3+ 3*4+ 0*5+ 1*6+ 5*7+ 1*8+ 8*9) mod 11|10
|X
|{{#expr:(0*1+ 5*2+ 9*3+ 3*4+ 0*5+ 1*6+ 5*7+ 1*8+ 8*9) mod 11}}
}}}}
Clearly this would be tedious to do by hand so all templates are expected to be set up by WP:bot.