User:Mheguy/Archive/001: Difference between revisions

From SGUTranscripts
Jump to navigation Jump to search
No edit summary
m (Mheguy moved page Template:PublishDate to User:Mheguy/Archive/001: Retiring the concept)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--
<includeonly>
Value provided:
{{{1}}}
Output:
{{#time: Y-m-d | {{{1}}}}}
</includeonly>
<noinclude>
<noinclude>
Welcome to my little sandbox.
A proof of concept to have a Single Source of Truth for the publish date of all episodes.
</noinclude>
</noinclude>
-->
 
<includeonly>
<!--
The variables extension is not enabled on this server. That means we need to re-calculate everything each time.
That's brutal.
 
Here's some debug code that you can un-comment to understand what we're doing here:
 
This will show the value that is passed to the template.
Input value: {{{1}}}
Input value: {{{1}}}


This will show a 4-character left-padded version of the value. Ex. "25" becomes "0025".
Left-padded value: {{padleft:{{{1}}}|4|0}}
Left-padded value: {{padleft:{{{1}}}|4|0}}


Get the fourth character from the right from the left-padded value.
If the original value is 1234, we return 1.
If the original value is 25, we return 0.
Left-padded value, trimmed to 1 char:{{padleft:|1|{{padleft:{{{1}}}|4|0}} }}
Left-padded value, trimmed to 1 char:{{padleft:|1|{{padleft:{{{1}}}|4|0}} }}


Defining var: {{#vardefine:paddedNumber|{{padleft:{{{1}}}|4|0}}}}
Get the third character from the right from the left-padded value.
If the original value is 1234, we return 2.
If the original value is 25, we return 0.
Left-padded value, trimmed to 1 char:{{padleft:|1|{{padleft:{{{1}}}|3|0}} }}


Padded number var: {{#var:paddedNumber}}
-->


 
<includeonly>
{{#switch: {{{1}}}
{{#switch: {{padleft:|1|{{padleft:{{{1}}}|4|0}} }}
| 0001 = 2005-05-04
  | 0 = {{PublishDate0000s|}}
  | 0002 = 2005-06-01
  | 1 = {{PublishDate1000s}}
| 0003 = 2005-06-07
  | 0004 = 2005-06-15
  | #default = 0000-00-00
  | #default = 0000-00-00
}}
}}
</includeonly>
</includeonly>
<noinclude>
A proof of concept to have a Single Source of Truth for the publish date of all episodes.
</noinclude>

Latest revision as of 13:57, 25 November 2024

A proof of concept to have a Single Source of Truth for the publish date of all episodes.