comparing revision 3 and revision 2
|
done comparing
BDateTime
Motivation
Date and time manipulation in php is a drag. So BDateTime to the rescue! (well maybe it’ll hand you a tissue or something.) -
Examples
Here’s an example of how you can use it, since I believe it’s important to see if something is easy to use before you waste your time on it.
Straight out of the unit test:$initial = BDateTime::fromString("2007-02-25 05:50:24");
$expected = BDateTime::fromString("2007-03-02 05:50:24");
// we should be able to add 5 days and expect the time to be maintained.
$this->assertTrue( $initial->addDays(5)->equals($expected) );
$initial = BDateTime::fromString("2007-02-25 05:50:24");
$expected = BDateTime::fromString("2007-02-25 06:10:27");
// test out the time manipulators in a fun example of chaining.
$this->assertTrue( $initial->addHours(1)->subtractMinutes(40)->addSeconds(3)->equals($expected) );
The application is unit tested using http //www.phpunit.de/, and more examples of how to use the class can be found in the package’s test directory.
Docs
Online documentation can be found here:
http //opensource.bitscribe.net/doc/bdatetime-0.1.0/classBDateTime.html
Download
You can download it here: http //opensource.bitscribe.net/downloads/bdatetime-0.1.0.tar.bz2
