Page MenuHomePhabricator

Adding Julian Date as Variable
Closed, ResolvedPublic

Description

Author: robert_horning

Description:
The motivation for this request is to provide a way that would allow Wikibooks
to put up a featured Wikibook on the main page that would appear on a rotation
schedule, similar to what is done for Wikipedia and Commons Featured
Articles/Pictures.

The short coming of this concept is that Wikibooks simply doesn't have enough
quality books to justify or warrant having a new book featured every day that is
brand new. I've created a template that currently uses a calculation using a
mod function and a psuedo "variable" that is really just a transcluded template:

{{Wikibooks:Featured Books/Book{{#expr: {{CURRENTDAY}} mod {{FEATURENUM}}}}}}

The problem here is that the CURRENTDAY variable only goes to 31 (on months with
31 days), and we need the ability to have a few more than just 31 featured
Wikibooks (although this is a short term solution). What I would like to see is
something more like this:

{{Wikibooks:Featured Books/Book{{#expr: {{JULIANDAY}} mod {{FEATURENUM}}}}}}

where the variable "JULIANDAY" is calculated according to the rough standards
listed on [[w:Julian Day]].

I believe this value is already calculated by MySQL and other DB servers, so it
is simply a matter of passing this information forward, although calculations of
this date aren't overly complicated. I'm sure that a very complicated
expression could also be generated using the values of "CURRENTDAY",
"CURRENTMONTH", and "CURRENTYEAR" to derive this date, although it could be
debated if the efficiency of doing this for something like a major project main
page is something worth doing. It also seems a bit strange to "recalculate" a
variable that already exists in the operating system and was used to calculate
the above three variables in the first place, or at least something very similar.

This does have value beyond just the very limited appeal for having a date
variable that can be manipulated for further calculations, and I think that this
is certainly something that can be extended in other directions as well.


Version: unspecified
Severity: enhancement
Platform: PC
URL: http://en.wikibooks.org/

Details

Reference
bz9200

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:39 PM
bzimport set Reference to bz9200.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

Wouldn't something like {{#expr:({{#date:U}}/86400) round 0}} work for you?

robert_horning wrote:

A better expression would be:

{{#expr:{{#time:U}}/86400 round 0}}

but yeah, that mostly does what I was looking for. Thanks. I'm going to create
a full Julian date template based off of this, which is trivial at this point.
Thank for pointing me in the right direction.

The only real problem here is the classical Unix MAXINT bug for when this number
rolls over, but I think that will be a larger issue for more than just the main
page of Wikibooks. Hopefully that bug will get a good work around that will be
better than the Y2K problems.