The logo poll for the 2021 4chan Winter Cup is now open. Logos are in this gallery. You can vote here.

Template talk:TimeDST

From Rigged Wiki
Jump to navigation Jump to search

Handling of DST

>Creating an entirely new template because I forgot to update the usual template on the weekend

Since it's done now, we should probably take this opportunity to do what should've been done long ago and simplify this template for easier maintenance and higher extensibility (Yurop and Straya?) before it gets out of control. Option #1 would be to just simplify the templates:

{{tt|{{{1}}}:{{{2}}}|Eastern Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 5/4 hours}}

Pacific Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 8/7 hours}}}}

Which gives us 17:00 and 17:00, the advantage being that both future and past times will be correct if the correct template is used and the disadvantage that one has to remember to use the correct template.

Option #2 would be to remove this template and adapt Template:Time to automatically switch DST on and off based on the current date:

{{#ifexpr: {{#expr: {{#time: U}} > {{#time: U|Second Sunday of March 7:00}}}} and {{#expr: {{#time: U}} < {{#time: U|First Sunday of November 6:00}}}}| {{tt|{{{1}}}:{{{2}}}|Eastern Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 4 hours}}&#10;Pacific Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 7 hours}}}} | {{tt|17:00|Eastern Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 5 hours}}&#10;Pacific Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 8 hours}}}}}}

Resulting in 17:00, which has the advantage of showing, in most cases, the correct time without wiki autists needing to worry about the correct template, but the disadvantage of times of past (and some future) events often being inaccurate.

A third option would be to use option #2 and expand the original template so that a specific date can be set which will be used for DST calculation, while also using the current date as a default if no date is set to keep backwards compatibility:

{{#ifexpr: {{#expr: {{#time: U|{{{3|{{CURRENTYEAR}}}}}-{{{4|{{CURRENTMONTH}}}}}-{{{5|{{CURRENTDAY}}}}} {{{1}}}:{{{2}}}}} > {{#time: U|Second Sunday of March {{{3|{{CURRENTYEAR}}}}} 7:00}}}} and {{#expr: {{#time: U|{{{3|{{CURRENTYEAR}}}}}-{{{4|{{CURRENTMONTH}}}}}-{{{5|{{CURRENTDAY}}}}} {{{1}}}:{{{2}}}}} < {{#time: U|First Sunday of November {{{3|{{CURRENTYEAR}}}}} 6:00}}}}| {{tt|{{{1}}}:{{{2}}}|Eastern Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 4 hours}}&#10;Pacific Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 7 hours}}&#10;DST checked for: {{{3|{{CURRENTYEAR}}}}}-{{{4|{{CURRENTMONTH}}}}}-{{{5|{{CURRENTDAY}}}}}}} | {{tt|{{{1}}}:{{{2}}}|Eastern Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 5 hours}}&#10;Pacific Time: {{#time: g:i a|{{{1}}}:{{{2}}} - 8 hours}}&#10;DST checked for: {{{3|{{CURRENTYEAR}}}}}-{{{4|{{CURRENTMONTH}}}}}-{{{5|{{CURRENTDAY}}}}}}}}}

This would result in something like 17:00 for {{Time|17|00|2017|3|1}}. This option allows for both the correctness of option #1 and the ease of use of option #2 at the cost of moderate additional effort over option #1 to achieve correctness. -- MerkaST (talk) 01:39, 16 March 2018 (UTC)