Talk:Date and time computing

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

Date and time computing (edit).

If the page rendering is slow, switch off "preview before first edit" in the preferences, and press edit to see the wikitext.

Meta killer[edit]

One or more of the templates used on Date and time computing are seriously broken, requests to get this page, or to see an edit preview, time out. -- Omniplex (w:t) 19:29, 1 June 2006 (UTC)

Perhaps the page is not broken, but just slow. Perhaps the page has to be split up, see also Date and time computing 1.
Maybe a side effect of the test wiki transfer. I don't have "preview before edit", and apparently it was only on pages using date math, but trhat could be a hallucination, because that's where I mostly edit / look at the moment. -- Omniplex (w:t) 11:25, 2 June 2006 (UTC)
I mean that if the page cannot be rendered, you neither can get the edit page if preview on first edit is on.--Patrick 11:35, 2 June 2006 (UTC)

Hi Xanthedoyle (talk) 15:39, 4 October 2019 (UTC)


I don't understand. What is the purpose of this page? — Ambush Commander(Talk) 23:00, 15 June 2006 (UTC)

And a more general question is: Why the heck do we need all these date templates? Wikitext is not a programming language (one of the big reasons why a built in #if template was so strongly opposed for a while). If there really is such a compelling need for date information that the category page describes as "curiosities", there should be a PHP based solution, not some macro-based implementation. — Ambush Commander(Talk) 00:09, 16 June 2006 (UTC)
Date math is required for pages like w:en:WP:BRION or the tip of the day. It's used to construct links, for an example see w:en:Wikipedia:Templates for deletion/Log.
There's nothing wrong with date math IFF you get it right, that's not always trivial, things to watch are:
  1. Leading zeros, see template:0expr (edittalklinkshistory) used by the BRION page, already working with optional substitution, therefore templates using it will be able to use its code inline without calling the additional template. Not yet available for all math templates, but getting better - four weeks after Patrick invented this technique AFAICT.
  2. Evaluations of more than one "current" variable per application, this results in race conditions near hh:mm:59. Some days ago I added a warning to Help:Variable and replaced {{CURRENTHOUR}} and {{CURRENTMINUTE}} in some critical places. Yesterday I simplified both to support inline optional substitution, improved the formula, added a strong warning, the works up to a TFD for w:en:Template:CURRENTSECOND.
Time math is a slightly different matter, we rarely need it to contruct links. The most interesting application are timezone conversions, on the BRION page I simply decided that Tuesday 00:00 UTC is good enough to get the most recent edition published on Monday local time. In essence time math is x*24*60*60 and details like leading zeros and rounding, harmless as soon as it works with an efficient formula ready for optional substitution.
Week math is tough, the ISO 8601 week number scheme is odd, and the related templates still need work, get rid of some auxiliary templates etc. Calculations in calendar weeks are popular in business applications, IIRC Wikizine also uses it. If you'd want to create a link to next week's whatever you need to know if that's ISO 8601 week 53 or 01. I can't tell you more about it, so far I didn't use it.
Using one common date math scheme like Modified Julian Dates in template:YMD2MJD (edittalklinkshistory) is only natural, or at least better than several different schemes in parallel. Counting days is fine, you can completely ignore times where they are irrelevant, and focus any {{IsLeapYear}} to the two places where it matters, conversions from or to day numbers. Using another epoch like Julian days is mostly a matter of taste, which date corresponds to "day 0". In practice it's not irrelevant, the ParserFunctions output is limited to about 12 significant digits, so for rare occasions where you really want date+time math (times as fractions) MJD is more accurate than JD for contemporary dates. For an exotic (wrt templates) example see MJD2sec. -- Omniplex (w:t) 01:51, 16 June 2006 (UTC)
Those are quite interesting applications, but if they're so complex, should they be implemented in PHP? (especially noting the performance effects of them from this page). — Ambush Commander(Talk) 02:01, 16 June 2006 (UTC)
Several of these templates are currently slow, but they can be made faster by doing computations in the template itself instead of calling other templates. Also, where only static output is needed, "subst" can be applied, so that the same computation is only done once.
If some of these templates are going to be heavily used and they are still slow after improvement, programming them in PHP might be considered.--Patrick 08:27, 16 June 2006 (UTC)
The thing is, it's not even a question about performance: programming these in PHP is trivial. date() can do most of the work for you. I realize it's not my place to tell you what to and not to do, but this seems like a lot of work for not very much. Heck, give me some specs and some test-cases and I could probably write the extension myself (or, as mentioned below, we might already have the code). — Ambush Commander(Talk) 15:17, 16 June 2006 (UTC)
I've done my part twice so far, REXX and templates, and some details are IMO not trivial. That's why we have test cases verified with independent sources. If you want to do something with PHP mediazilla:5678 would be more important, it's kind of annoying that I've no clue why #ifeq: works under all tested conditions wrt subst:, but most other colon functions like #if: fail miserably. Or fix the weird implementation of div and mod, waiting until everybody got used to their odd behaviour inventing horrible workarounds used on thousands of pages in dozens of projects is no good plan. -- Omniplex (w:t) 16:25, 16 June 2006 (UTC)
I'll take a look at the bug, but triviality works both ways. If it is trivial in PHP, then use PHP! If it's not trivial in PHP, use PHP anyway: it's probably more complicated in a macro-based programming language. — Ambush Commander(Talk) 20:54, 16 June 2006 (UTC)
Div and mod have been fixed (but need to be committed). Whee! Will you consider laying off with the algorithmic wikitext now? — Ambush Commander(Talk) 23:19, 16 June 2006 (UTC)


Didn't realise this stuff existed at the time I created it, but my DateTime Template Function seems to cover most things related here. Seems far more elegant than the options provided by wiki itself, IMO (of course). --Barthax 09:15, 16 June 2006 (UTC)

This seems to be formatting only, while the templates here mainly do computations to find a date, a number of days, etc.--Patrick 12:17, 16 June 2006 (UTC)


Gramma Xanthedoyle (talk) 15:40, 4 October 2019 (UTC)