Marko,
I list YouTube videos with Zend_Gdata_Youtube.
From youtube I get duration in seconds.
I made conversion with Zend_Measure with following code:
// example: duration 188s
$input = new Zend_Measure_Time($videoEntry->getVideoDuration(),
Zend_Measure_Time::SECOND);
// example outputs 3.13min which is correct: 188/60=3.13
echo $input->convertTo('MINUTE');
BUT, should it make 3 min 8 s kinda string? Now I have no use for this
conversion
and I propably end up making view helper converting seconds to
minutes+seconds.
I just wanted to ask if anybody knows better way or something about
Zend_Measure that I have missed.
Zend_Measure handles measurements.
First you have seconds, but what you expect is to get 2 measurements
returned.
Seconds and Minutes... from Zend_Measures point of view the returned value
is correct.
You wanted to have minutes and written in minutes the result is a float.
But you want to get a time value and not one measurement.
So, when you want to have date calculations then you should use Zend_Date.
In this case the simplest way is to call:
$date = Zend_Date(188, Zend_Date:SECONDS);
$date->toArray();
or
$date->toString('mm.ss');
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com