Difference between revisions of "Template:Dow holiday"

From Geohashing
imported>Tjtrumpet2323
(GAAH!!!! I left a test {{#vardefine:date|2010-04-02}} in this template?!??!?! WHY?!!)
imported>Mattyk
m (renamed variable 'date' to 'qdate', for namespace issues.)
Line 1: Line 1:
<includeonly>{{#vardefine:date|{{{1|{{CURRENTTIMESTAMP}}}}}}}{{#ifexpr: {{#time:N|{{#var:date}}}} <= 5 | {{#vardefine:weekday|1}} | {{#vardefine:weekday|0}} }}{{#switch: {{#time:m|{{#var:date}}}}
+
<includeonly>{{#vardefine:qdate|{{{1|{{CURRENTTIMESTAMP}}}}}}}{{#ifexpr: {{#time:N|{{#var:qdate}}}} <= 5 | {{#vardefine:weekday|1}} | {{#vardefine:weekday|0}} }}{{#switch: {{#time:m|{{#var:qdate}}}}
  | 1 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = 1 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:date}}}} = 2 and {{#time:N|{{#var:date}}}} = 1) or ({{#time:j|{{#var:date}}}} = {{weekday in month|{{#time:Y|{{#var:date}}}}|1|1|3}}) | 1 | 0}}
+
  | 1 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = 1 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:qdate}}}} = 2 and {{#time:N|{{#var:qdate}}}} = 1) or ({{#time:j|{{#var:qdate}}}} = {{weekday in month|{{#time:Y|{{#var:qdate}}}}|1|1|3}}) | 1 | 0}}
  | 2 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = {{weekday in month|{{#time:Y|{{#var:date}}}}|2|1|3}}) | 1 | 0}}
+
  | 2 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = {{weekday in month|{{#time:Y|{{#var:qdate}}}}|2|1|3}}) | 1 | 0}}
  | 3 = {{#ifexpr: ({{#time:Ymd|{{#var:date}}}} = {{#time:Ymd|{{Easter|{{#time:Y|{{#var:date}}}}}} -2 days}}) | 1 | 0}}
+
  | 3 = {{#ifexpr: ({{#time:Ymd|{{#var:qdate}}}} = {{#time:Ymd|{{Easter|{{#time:Y|{{#var:qdate}}}}}} -2 days}}) | 1 | 0}}
  | 4 = {{#ifexpr: ({{#time:Ymd|{{#var:date}}}} = {{#time:Ymd|{{Easter|{{#time:Y|{{#var:date}}}}}} -2 days}}) | 1 | 0}}
+
  | 4 = {{#ifexpr: ({{#time:Ymd|{{#var:qdate}}}} = {{#time:Ymd|{{Easter|{{#time:Y|{{#var:qdate}}}}}} -2 days}}) | 1 | 0}}
  | 5 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = {{weekday in month|{{#time:Y|{{#var:date}}}}|5|1|-1}}) | 1 | 0}}
+
  | 5 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = {{weekday in month|{{#time:Y|{{#var:qdate}}}}|5|1|-1}}) | 1 | 0}}
 
  | 6 = 0
 
  | 6 = 0
  | 7 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = 3 and {{#time:N|{{#var:date}}}} = 5) or ({{#time:j|{{#var:date}}}} = 4 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:date}}}} = 5 and {{#time:N|{{#var:date}}}} = 1) | 1 | 0}}
+
  | 7 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = 3 and {{#time:N|{{#var:qdate}}}} = 5) or ({{#time:j|{{#var:qdate}}}} = 4 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:qdate}}}} = 5 and {{#time:N|{{#var:qdate}}}} = 1) | 1 | 0}}
 
  | 8 = 0
 
  | 8 = 0
  | 9 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = {{weekday in month|{{#time:Y|{{#var:date}}}}|9|1|1}}) | 1 | 0}}
+
  | 9 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = {{weekday in month|{{#time:Y|{{#var:qdate}}}}|9|1|1}}) | 1 | 0}}
 
  | 10 = 0
 
  | 10 = 0
  | 11 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = {{weekday in month|{{#time:Y|{{#var:date}}}}|11|4|4}}) | 1 | 0}}
+
  | 11 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = {{weekday in month|{{#time:Y|{{#var:qdate}}}}|11|4|4}}) | 1 | 0}}
  | 12 = {{#ifexpr: ({{#time:j|{{#var:date}}}} = 24 and {{#time:N|{{#var:date}}}} = 5) or ({{#time:j|{{#var:date}}}} = 25 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:date}}}} = 26 and {{#time:N|{{#var:date}}}} = 1) or ({{#time:j|{{#var:date}}}} = 31 and {{#time:N|{{#var:date}}}} = 5) | 1 | 0}}
+
  | 12 = {{#ifexpr: ({{#time:j|{{#var:qdate}}}} = 24 and {{#time:N|{{#var:qdate}}}} = 5) or ({{#time:j|{{#var:qdate}}}} = 25 and {{#var:weekday}} = 1) or ({{#time:j|{{#var:qdate}}}} = 26 and {{#time:N|{{#var:qdate}}}} = 1) or ({{#time:j|{{#var:qdate}}}} = 31 and {{#time:N|{{#var:qdate}}}} = 5) | 1 | 0}}
 
  | #default = 0
 
  | #default = 0
 
}}</includeonly><noinclude>
 
}}</includeonly><noinclude>

Revision as of 01:24, 10 December 2008

Usage

{{Dow holiday|2008-11-27}}

  • Date must be passed in YYYY-MM-DD format.
  • Returns 1 if the date passed is a Dow holiday; 0 otherwise.
    • Weekends return 0 and are not treated as holidays, as they can be programmatically handled by other templates.
    • All holidays are systematically and calculationally determined.

See also

NYSE Calendar