Category talk:Time

From mediawiki.org
Latest comment: 14 years ago by Rdavout in topic Operations on time

Operations on time[edit]

It seems nothing exists to do operations on time (comparing dates and the such). I wrote some quick and dirty code in some templates to help me with that. Just in case this may help somebody, I thought I would share. I needed to compare a YYYY-mm-dd format date to the present timestamp (is that date in the past, in the future, etc...) to get a functional workflow management system with different priorities assigned to different timeboxes.

The base template, used and built upon in different ways, is the following:

{{#expr: {{#expr:({{CURRENTYEAR}} <= {{#time: Y | {{{1}}} }}) }} and {{#expr:({{CURRENTMONTH}} <= {{#time: m | {{{1}}} }}) }} and {{#expr:({{CURRENTDAY}} <= {{#time: d | {{{1}}} }}) }} }}

In this precise case, I called the template {{date-greaterorequalthan-present}} and the call function therefore is {{date-greaterorequalthan-present|}}, the output being a boolean value.

Rdavout 23:23, 4 August 2009 (UTC) Rdavout 23:41, 4 August 2009 (UTC)Reply

UPDATE: Much more powerful - w:en:Template:DATECOMP2. You have to use a specific date input and lots of Wikipedia templates to get this going, but once they're rolling, powerful time operations are made possible. Rdavout 14:35, 11 August 2009 (UTC)Reply