2017 © Pedro Peláez
 

library datetimems

DateTime with microseconds awareness and calculations.

image

bvarent/datetimems

DateTime with microseconds awareness and calculations.

  • Tuesday, December 2, 2014
  • by bvarent
  • Repository
  • 1 Watchers
  • 3 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

DateTimeMS

This small library enables you to make time calculations with microseconds precisions. PHP's built-in DateTime and DateInterval classes will not do that. Except that DateTime does keep microseconds, but will ignore those in its calculations., (*1)

Usage

Require this library via composer., (*2)

Use in the same way as you would DateTime. The classes extend DateTime, so you can substitute your legacy classes where needed., (*3)

Example: php $dtToday = new \DateTimeMS(); $dtTomorrow = clone $dtToday; $dtTomorrow->modify("+1 day -1 microsecond"); $interval = $dtToday->diff($dtTomorrow); print "In between {$dtToday->format('D, H:i:s.u')} and the same second tomorrow are $interval->format('%d days, %h hrs, %i mins, %secs and %u microsecs').", (*4)

Warnings

  • The comparison operators (< > = etc) do not account for microseconds. (Which is impossible to achieve due to nonexistence of PHP operator overloading.)
  • DateTimeMS::modify cannot be used to set microseconds explicitly.
  • DateIntervalMS::modify is not implemented.

ToDo

  • Improve DateTimeMS::modify
  • Implement DateIntervalMS::modify
  • Expand the unit tests.
  • Test and think about performance.

The Versions

02/12 2014

dev-master

9999999-dev

DateTime with microseconds awareness and calculations.

  Sources   Download

LGPL-3.0+

The Development Requires

by Avatar bvarent

02/12 2014

v1.1.0

1.1.0.0

DateTime with microseconds awareness and calculations.

  Sources   Download

LGPL-3.0+

The Development Requires

by Avatar bvarent

13/10 2014

v1.0.0

1.0.0.0

DateTime with microseconds awareness and calculations.

  Sources   Download

The Development Requires

by Roel Arents