Template:Dr-logno

{{#switch:{{{3}}}|y={{#expr:{{#ifexpr:{{{1}}}<0|{{{1}}}+1|{{{1}}}}}+{{{2|0}}}}}|d={{#expr:{{#ifexpr:{{{1}}}<0|-1+({{{1}}} - {{{1}}} mod 10)/10|({{{1}}} - {{{1}}} mod 10)/10}}+{{{2|0}}}}}|c={{#expr:{{#ifexpr:{{{1}}}<0|1+({{{1}}}-99 - ({{{1}}}-99) mod 100)/100|({{{1}}}+99 - ({{{1}}}+99) mod 100)/100}}+{{{2|0}}}}}|m={{#expr:{{#ifexpr:{{{1}}}<0|1+({{{1}}}-999 - ({{{1}}}-999) mod 1000)/1000|({{{1}}}+999 - ({{{1}}}+999) mod 1000)/1000}}+{{{2|0}}}}} Converts a year (first parameter, e.g. 1998 for 1998 AD, -1998 for 1998 BC) into a logically-numbered year/decade/century/millennium. For use in {{tl|dr}}). Applies an offset (second parameter; defaults to 0). Third parameter is y/d/c/m.