Simetrical wrote:
On 8/27/06, Tim Starling t.starling@physics.unimelb.edu.au wrote:
I have written a new parser function for time and date formatting, called #time. It is an interface to Language::sprintfDate, a function which I wrote a few weeks ago to support internationalisation. Documentation is at:
http://meta.wikimedia.org/wiki/ParserFunctions#.23time
It allows things like {{#time:F|+2 hours}} to get the month name in CEST.
Excellent! This will make a ton of ridiculously complicated templates obsolete. Could you add the rest of the letter codes? I'm sure people would find U useful if they needed to do date arithmetic, for instance. It shouldn't reduce performance, since the case statements would be at the end and therefore just ignored unless they match, right?
I assume (and hope) PHP case statements are implemented with a hashtable, otherwise they would be very inefficient. I have no problem with adding more format characters in principle, it's just a matter of development time.
This time formatter would probably be one of the slowest parts of the parser per-character, which is why I used memoization and a 1000-byte limit on actual (post-memoize) processing per page, since the initial commit. Hopefully the limit won't affect any legitimate users.
-- Tim Starling