Jump to content

Template:Copyright: Difference between revisions

From Continuum Universes Wiki
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
== Examples ==
== Examples ==
{{Copyright|year=2021|name=Jensen Saga Studio}}{{Copyright|2021|Jensen Saga Studio}}{{Copyright|name=Jensen Saga Studio}}  
{{Copyright|year=2021|name=Jensen Saga Studio}}{{Copyright|2021|Jensen Saga Studio}}{{Copyright|name=Jensen Saga Studio}}  
</noinclude><includeonly>
</noinclude><includeonly>{{#switch: {{#if:{{{name|{{{2|}}}}}}|1|0}}
<!-- If name is missing, error out -->
  | 0 = {{#tag:span|Copyright error: missing name.|class=error}}
{{#switch: {{#if:{{{name|{{{2|}}}}}}|1|0}}
  | 0 = <span class="error">Copyright error: missing name.</span>
  | 1 =
  | 1 =
  <!-- If year is omitted, use current year -->
   {{#if:{{{year|{{{1|}}}}}}|
   {{#if:{{{year|{{{1|}}}}}}|
    <!-- Year provided: must be numeric and not in the future -->
     {{#iferror:{{#expr: {{{year|{{{1|}}}}}} + 0 }}|
     {{#iferror:{{#expr: {{{year|{{{1|}}}}}} + 0 }}|
       <span class="error">Copyright error: invalid year “{{{year|{{{1|}}}}}}”.</span>|
       {{#tag:span|Copyright error: invalid year “{{{year|{{{1|}}}}}}”.|class=error}}|
       {{#ifexpr: {{{year|{{{1|}}}}}} > {{#time:Y}} |
       {{#ifexpr: {{{year|{{{1|}}}}}} > {{#time:Y}} |
         <span class="error">Copyright error: year “{{{year|{{{1|}}}}}}” is in the future.</span> |
         {{#tag:span|Copyright error: year “{{{year|{{{1|}}}}}}” is in the future.|class=error}} |
        <!-- Year is valid and <= current year -->
         {{#ifexpr: {{{year|{{{1|}}}}}} = {{#time:Y}} |
         {{#ifexpr: {{{year|{{{1|}}}}}} = {{#time:Y}} |
           <div class="copyright">&copy; {{#time:Y}} {{{name|{{{2|}}}}}}</div> |
           {{#tag:div|&copy; {{#time:Y}} {{{name|{{{2|}}}}}}|class=copyright}} |
           <div class="copyright">&copy; {{{year|{{{1|}}}}}}&ndash;{{#time:Y}} {{{name|{{{2|}}}}}}</div>
           {{#tag:div|&copy; {{{year|{{{1|}}}}}}&ndash;{{#time:Y}} {{{name|{{{2|}}}}}}|class=copyright}}
         }}
         }}
       }}
       }}
     }}
     }}
   |
   |
     <!-- No year given -->
     {{#tag:div|&copy; {{#time:Y}} {{{name|{{{2|}}}}}}|class=copyright}}
    <div class="copyright">&copy; {{#time:Y}} {{{name|{{{2|}}}}}}</div>
   }}
   }}
}}
}}</includeonly>
</includeonly>
<noinclude>
<noinclude>
[[Category:Licensing templates]] [[Category:Image license templates]] [[Category:Templates]]
[[Category:Licensing templates]] [[Category:Image license templates]] [[Category:Templates]] [[Category:File license templates]]
</noinclude>
</noinclude>

Latest revision as of 12:31, 4 October 2025

This template prints a copyright notice with sane year logic.

Usage:

{{Copyright|year=2021|name=Jensen Saga Studio}}
{{Copyright|2021|Jensen Saga Studio}}         <!-- positional works too -->
{{Copyright|name=Jensen Saga Studio}}         <!-- year omitted -> current year -->
{{Copyright|2026|name=Jensen Saga Studio}}    <!-- will give error if year is ahead of current -->

Examples