Jump to content

Template:APOD: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Tom.Reding moved page Template:APOD to Template:Cite APOD: More appropriate name per {{Cite web}}-wrapping functionality - {{APOD}} will be used for non-reference (i.e. ==External links==) purposes
 
Sync date handling with Template:Cite APOD
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<includeonly>[https://apod.nasa.gov/apod/ap{{#if: {{#invoke:ustring|match|\{{{date|}}}|^%d%d%d%d}}|<!--
#REDIRECT [[Template:Cite APOD]]

{{R from move}}
Y *is* in front. Now check month: m & mm ok, mmm & mmmm bad.
-->{{#iferror: {{#expr:{{#invoke:string|sub|{{{date|}}}|6|7}} * 1}}|<!--

mmm & mmmm bad:
{{date|yyyy mmm d|iso}} doesn't work, so YMD needs to be reformatted to an acceptable format.
YMD: --> {{#if:{{{date|}}}|<!--
YMD input Y-->{{#invoke:ustring|gsub|\{{date|{{#invoke:string|sub|{{{date|}}}|1|4}}-<!--
YMD input M-->{{MONTHNUMBER|{{#invoke:string|sub|{{{date|}}}|6|8}}}}-<!--
YMD input D-->{{padleft:{{#invoke:string|sub|{{{date|}}}|-2|-1}}|2}}<!--
YMD output -->|iso}}|..(..).(..).(..)|%1%2%3}}.html}}|<!--

m & mm ok:
-->{{#if:{{{date|}}}|{{#invoke:string|replace|1={{date|{{{date|}}}|iso}}|2=^..(..).(..).(..).*|3=%1%2%3|plain=0}}.html}}}}
|<!--

!YMD (yyyy is not in front): -->{{#if:{{{date|}}}|{{#invoke:string|replace|1={{date|{{{date|}}}|iso}}|2=^..(..).(..).(..).*|3=%1%2%3|plain=0}}.html}} }} NASA Astronomy Picture of the Day: {{{title|}}} ({{{date|}}})]</includeonly><noinclude>
{{Documentation}}
</noinclude>

Latest revision as of 20:54, 18 November 2021