Difference between revisions of "Template:SetDatePropertyValue"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
Line 9: Line 9:
  
 
'''NOTE:''' As any "set" template, it doesn't print anything on the page, but merely sets the appropriate values.
 
'''NOTE:''' As any "set" template, it doesn't print anything on the page, but merely sets the appropriate values.
 
'''As of now, the function doesn't support BC years.'''
 
  
 
'''Parameters:'''
 
'''Parameters:'''
 
* <code><nowiki>|property=</nowiki></code> - the name of the property.
 
* <code><nowiki>|property=</nowiki></code> - the name of the property.
* <code><nowiki>|year=</nowiki></code> - the year.
+
* <code><nowiki>|year=</nowiki></code> - the year. '''YYYY BC and YYYY BCE formats are allowed for BC years.'''
 
* <code><nowiki>|month=</nowiki></code> - the month.
 
* <code><nowiki>|month=</nowiki></code> - the month.
 
* <code><nowiki>|day=</nowiki></code> - the day.
 
* <code><nowiki>|day=</nowiki></code> - the day.
Line 23: Line 21:
 
  --><!-- set individual values and build the overall date string
 
  --><!-- set individual values and build the overall date string
 
  -->|{{#if: {{{year|}}}<!--
 
  -->|{{#if: {{{year|}}}<!--
   -->|{{#if: {{{month|}}}<!--
+
  --><!--
 +
  --><!-- check if BC this is a BC year
 +
   -->|{{#if: {{#pos:{{{year|}}}|BC}}<!--
 +
    -->|{{#vardefine: varYear|{{#sub:{{{year|}}}|0|{{#pos:{{{year|}}}|BC}}}}}}<!-- remove BC from the year to use time functions
 +
    -->|{{#vardefine: varYear|{{{year|}}}}<!--
 +
    -->}}<!-- if BC
 +
    --><!--
 +
    --><!--
 +
    --><!--
 +
    -->{{#if: {{{month|}}}<!--
 
     -->|{{#if: {{{day|}}}<!--
 
     -->|{{#if: {{{day|}}}<!--
       -->|{{#set: {{{property|}}} Year={{#time:Y|{{{year|}}}-{{{month|}}}-{{{day|}}} }}|}}<!-- store year
+
       -->|{{#set: {{{property|}}} Year={{#time:Y|{{#var:varYear}}-{{{month|}}}-{{{day|}}} }} |}}<!-- store year
         -->{{#set: {{{property|}}} Month={{#time:F|{{{year|}}}-{{{month|}}}-{{{day|}}} }}|}}<!-- store month
+
         -->{{#set: {{{property|}}} Month={{#time:F|{{#var:varYear}}-{{{month|}}}-{{{day|}}} }}|}}<!-- store month
         -->{{#set: {{{property|}}} Day={{#time:j|{{{year|}}}-{{{month|}}}-{{{day|}}} }}|}}<!-- store day
+
         -->{{#set: {{{property|}}} Day={{#time:j|{{#var:varYear}}-{{{month|}}}-{{{day|}}} }}|}}<!-- store day
         -->{{#set: {{{property|}}}={{#time:j F Y|{{{year|}}}-{{{month|}}}-{{{day|}}} }}|}}<!-- all components are present   
+
         -->{{#set: {{{property|}}}={{#time:j F Y|{{#var:varYear}}-{{{month|}}}-{{{day|}}} }}|}}<!-- all components are present   
       -->|{{#set: {{{property|}}} Year={{#time:Y|{{{year|}}}-{{{month|}}}-28 }}|}}<!-- store year
+
       -->|{{#set: {{{property|}}} Year={{#time:Y|{{#var:varYear}}-{{{month|}}}-28 }}|}}<!-- store year
         -->{{#set: {{{property|}}} Month={{#time:F|{{{year|}}}-{{{month|}}}-28 }}|}}<!-- store month
+
         -->{{#set: {{{property|}}} Month={{#time:F|{{#var:varYear}}-{{{month|}}}-28 }}|}}<!-- store month
         -->{{#set: {{{property|}}}={{#time:F Y|{{{year|}}}-{{{month|}}}-28 }}|}}<!-- only month and year are present
+
         -->{{#set: {{{property|}}}={{#time:F Y|{{#var:varYear}}-{{{month|}}}-28 }}|}}<!-- only month and year are present
 
       -->}}<!-- if day
 
       -->}}<!-- if day
     -->|{{#set: {{{property|}}} Year={{#time:Y|{{{year|}}} }}|}}<!-- store year  
+
     -->|{{#set: {{{property|}}} Year={{#time:Y|{{#var:varYear}} }} {{#if: {{#pos:{{{year|}}}|BC}}|BC|}} |}}<!-- store year  
       -->{{#set: {{{property|}}}={{#time:Y|{{{year|}}} }}|}}<!-- only year is present   
+
       -->{{#set: {{{property|}}}={{#time:Y|{{#var:varYear}} }}|}}<!-- only year is present   
 
     -->}}<!-- if month
 
     -->}}<!-- if month
 
   --><!--
 
   --><!--

Revision as of 23:09, 23 August 2016

This template is used to set a value of type date given the year, month, and day. Month and day are optional parameters. The template will also store all the parts individually to keep track of which parts of the date are incomplete.

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.
  • |year= - the year. YYYY BC and YYYY BCE formats are allowed for BC years.
  • |month= - the month.
  • |day= - the day.