PHP has killed Swatch beats?
I just noticed that the time information on my blog had been replaced with [B unsupported]. Looks like some sneak-update my hoster pulled off also snuck in a change to date format string parsing. Apparently the PHP guys deprecated the B format option that lets you display the time in Swatch internet beats aka metric time.
I couldn't find any info on that on the web, so I guess it was a silent, relatively low-profile change. Anyone know any details?
Update: Okay, so I added a workaround and wrote myself a little beat-safe version of date:
function beatsafe_date( $fmtstr )
{
$beatsperminute = 1.440;
$hours = date("H");
$mins = date("i");
$mins += $hours *60;
$beats = $mins * $beatsperminute;
$beatsstr = floor($beats % 1000);
while( strlen($beatsstr) < 3 )
$beatsstr = "0".$beatsstr;
$fmtstr = str_replace( "B", $beatsstr, $fmtstr );
return date( $fmtstr );
}
This doesn't yet handle the optional parameter containing a timestamp, but I didn't need that. If you do, it should be easy to add that to the three date() calls in there. To be correct, this should probably also try to set up the correct time zone, but since Biel and Heidelberg are in the same time zone, I don't have to worry about that.
|