Difference between revisions of "Template:SetDatePropertyValueFromDateString"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
Line 27: Line 27:
 
     -->{{#switch: {{#var: varSlash1}}<!--
 
     -->{{#switch: {{#var: varSlash1}}<!--
 
     -->|0={{#if: {{{reporterror|}}}| The datestring of property {{{property|}}} doesn't contain any date. |}}<!-- slash is the first symbol: don't do anyhting
 
     -->|0={{#if: {{{reporterror|}}}| The datestring of property {{{property|}}} doesn't contain any date. |}}<!-- slash is the first symbol: don't do anyhting
     -->|{{#vardefine: varYear|{{#sub:{{{datestring|}}}|0|{{#expr: {{#var: varSlash1}}}} }}|}}<!-- extract the year  
+
     -->|={{#vardefine: varYear|{{{datestring|}}}|}}<!-- empty: assume that only the year is given
 +
    -->|#default= here {{#vardefine: varYear|{{#sub:{{{datestring|}}}|0|{{#expr: {{#var: varSlash1}}}} }}|}}<!-- extract the year  
 
       -->{{#vardefine: varSlash2|{{#pos:{{{datestring|}}}|/|{{#expr: {{#var: varSlash1}}+1}} }}|}}<!-- search for the next occurrence of slash
 
       -->{{#vardefine: varSlash2|{{#pos:{{{datestring|}}}|/|{{#expr: {{#var: varSlash1}}+1}} }}|}}<!-- search for the next occurrence of slash
 
       -->{{#if: {{#var: varSlash2}}<!--
 
       -->{{#if: {{#var: varSlash2}}<!--
Line 37: Line 38:
  
 
       --><!--
 
       --><!--
    -->|={{#vardefine: varYear|{{{datestring|}}}|}}<!-- empty: assume that only the year is given
 
 
     -->}}<!--
 
     -->}}<!--
 
   -->year={{#var: varYear}} month={{#var: varMonth}} day={{#var: varDay}}<!--
 
   -->year={{#var: varYear}} month={{#var: varMonth}} day={{#var: varDay}}<!--

Revision as of 10:31, 24 August 2016

This template takes a date string in yyyy/mm/dd format and stores it as a complex date property value using Template:SetDatePropertyValue. This whole headache is necessary to support incomplete date values with BC support.

The template will store up to four values:

  • {{{property|}}} - the combined date.
  • {{{property|}}} Year - the year part.
  • {{{property|}}} Month - the month part.
  • {{{property|}}} Day - the day part.

NOTE: As any "set" template, it doesn't print anything on the page, but merely sets the appropriate values.

Parameters:

  • |property= - the name of the property.
  • |datestring= - the date value in yyyy/mm/dd format. The month and day are optional. YYYY BC and YYYY BCE formats are allowed for BC years.
  • |reporterror= - if given, an error message will be printed if no date is found in datestring.