What calculations, exactly, can you cache between calls for the life of the page?
In a typical page, you're calling it ~20 times, each with a different time each time.
It's also potentially different for different users, further eroding the value of cache, no?
Did you try it with %-e ?
The "-" option requests no padding.
I'm now thoroughly confused. You wanted to deal with the left spacing on the number, and suggested using trim(), I just suggested a variation on that which didn't use %e, nothing more.
For cases where there's an extra space in the middle of the string, you're still stuffed either way, whether you use ltrim() or trim(), aren't you?
My goal was initially to fix %e to return no padding. However, I don't really care that %e returns an extra space when HTML will deal with it. It's not a big deal... So, in the meantime I figured I should just call ltrim() on the final string (" 2 Décembre"). Do you understand what I mean...?
There is no magic st/nd/rd in PHP AFAIK.
<?php
// Prints something like: Monday 8th of August 2005 03:12:46 PM
date('l jS \of F Y h:i:s A');
?>dgudgeon at example dot com 14-Jul-2011 05:04
If moving from date() to strftime() to support additional languages, you may miss the ordinal suffix format option date('S'). Workaround this by adding an extra modifier (%O).
<?php
function my_strftime ($format, $timestamp)
{
$format = str_replace('%O', date('S', $timestamp), $format);
return strftime($format, $timestamp);
}
?>Is there not an actual linguistic equivalent in French for 2nd? I always thought there was.
And sadly there isn't a good way around this one - normally it's not a huge problem because most of the time we only have _1 and _n strings in English which will naturally be overridden in other languages. I don't think you can get around it, unless you drop it in English entirely and just leave it in other languages if they want to do so.
Yay, dates are just as much of a shit to cope with as timezones are!
Consider this: April 1 - that's mostly how the Americans write it, and it's wrong, because it should really be April 1st, never mind the implied but missing 'the' in the middle that you mention.
But the English get it wrong too. We tend to write 1 April or 1st April, but that's linguistically wrong too - it's really '1st (of) April' with the implication of 'day' being in there.
Fortunately most people aren't anal enough to care about this and don't really notice it when it's 1 April or April 1 with or without the suffix, it's only those of us who *really* put in the attention to detail that would even notice, let alone do anything about it.
(For the record, it's something I'd like to see done right too, but I didn't know enough about how other languages did it to make a judgement call on how it should be done)
Isn't this a complete list of all timezones?
Also, is the fact that I was by default on UTC/Dublin due to me probably not going to that area before, and thus having no default timezone...? Because I saved my time format, and didn't notice the timezone at that moment, and I immediately got an incorrect forum time (well, YOUR correct forum time if you prefer :P). I had to go back to the page and noticed that it was Dublin by default.
No, it's not a complete list of all timezones. There are nearly 500 (no that's not a typo) timezones to contend with. I've reduced it to a list of about 70 (75 IIRC) which are comparable to the ones Windows uses. Incidentally I think you'll find XenForo uses a similar if not the same list.
Check the timezone column in wedge_members to see what it's actually using for you - I'm on UTC Dublin, despite the server not being so.
Also, as far as I can determine, Amsterdam is not the same physical timezone but shares all the same rules with the Central European timezones, so that it is to all intents and purposes the same.
Regarding dates, I don't have a better solution, I'd prefer it to be as 'right' as possible, ultimately. April 1st would be better than April 1 which would be better than 1 April, but it's almost more a preference than anything else right now.
And yeah, optimising timeformat is one of those cases that it'd be neat but ultimately not a huge win in the scheme of things (IIRC, I already did some work to make it faster than SMF's by changing the setlocale call handling)
Getting back to the most immediate topic at hand (suffixes for dates), ignore the English suffixes when a non-English language is in use. Over-write the strings if that would help...
since no timezones exist that require a 15mn granularity,
So I changed my time format but forgot to also set my timezone, and as a result my forum pages were all showing dates that were late by one hour.
No, can't do something specific like that... It would need to be built into the language loader (i.e. load English, and if another language is loaded, unset all English suffixes), and I don't really like the idea.
$txt['day_suffix'] = array(
1 => 'st',
2 => 'nd',
3 => 'rd',
'n' => 'th',
);But surely you can't do it only once?
If you load French, you load French after you load English... so you need to rebuild it when French is loaded - surely you need to do it just when $template_name === 'index' so that you always rebuild it properly when changing languages?