Uli's Web Site
[ Zathras.de - Uli's Web Site ]
Other Sites: Stories
Pix
Abi 2000
Stargate: Resurgence
Lost? Site Map!
 
 
     home | blog | moose | programming | articles >> blog

 Blog Topics
 
 Archive
 

15 Most Recent [RSS]

 Less work through Xcode and shell scripts
2011-12-16 @600
 
 iTunesCantComplain released
2011-10-28 @954
 
 Dennis Ritchie deceased
2011-10-13 @359
 
 Thank you, Steve.
2011-10-06 @374
 
 Cocoa Text System everywhere...
2011-03-27 @788
 
 Blog migration
2011-01-29 @520
 
 All you need to know about the Mac keyboard
2010-08-09 @488
 
 Review: Sherlock
2010-07-31 @978
 
 Playing with Objective C on Debian
2010-05-08 @456
 
 Fruit vs. Obst
2010-05-08 @439
 
 Mixed-language ambiguity
2010-04-15 @994
 
 Uli's 12:07 AM Law
2010-04-12 @881
 
 Uli's 1:24 AM Law
2010-04-12 @874
 
 Uli's 6:28 AM Law
2010-04-12 @869
 
 Uli's 3:57 PM Law
2010-04-12 @867
 

More...

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.

Reader Comments: (RSS Feed)
No comments yet
Or E-Mail Uli privately.

 
Created: 2005-11-26 @ 18:57 Last change: 2005-11-26 @683 | Home | Admin | Edit
© Copyright 2003-2024 by M. Uli Kusterer, all rights reserved.