Statistics
2863
0
0
45d
Badges
Tags
utils
Dependencies

DateUtils library

Build Status Coverage Status Scrutinizer Code Quality

Library for easier working with date intervals.

Installation

composer require sunfoxcz/date-utils

Usage

IntervalFactory::createInterval()

<?php declare(strict_types=1);

use Sunfox\DateUtils\DateTime;
use Sunfox\DateUtils\DateIntervalFactory;

$start = new DateTime('2015-01-01');
$end = new DateTime('2015-12-31');

$months = DateIntervalFactory::create($start, $end, DateIntervalFactory::MONTH, 1, [
	'incomes' => [],
	'expenses' => [],
]);

foreach ($months as $k => $month) {
	echo "{$k}: " . $month->date->format('Y-m-d') . PHP_EOL;
}

SpentTime()

<?php declare(strict_types=1);

use Sunfox\DateUtils\SpentTime;

$spentTime = new SpentTime('1h30m');

echo (string) $spentTime; // 01:30:00
echo $spentTime->getTotalHours(); // 1,5
echo $spentTime->getTotalMinutes(); // 90
echo $spentTime->getTotalSeconds(); // 5400

For more usages Look into tests directory.

  • v.1.1.2 1.1.2

    • Fixed bug in SpentTime::add() method
  • v1.1.1 1.1.1

    • added SpentTime class
  • v1.1.0 Released version 1.1.0

    This version allows use with nette/utils 3.0

  • v1.0.0 Released version 1.0.0

    After long time of use in production, version 1.0.0 can be tagged. I made few changes before:

    • Dropped PHP 5.6 and 7.0 support
    • Added Travis check for PHP 7.3 (code is fully compatible)
    • Fixed test coverage repor on Scrutinizer, which is 100%
    • Updated coding style and added EasyCodingStandard for automated checks
    • Make use of PHP 7.1 new features
    • Added declare(strict_types=1) and scalar typehints to code
  • v0.5.0 Released version 0.5.0

    • Dropped HHVM support
    • Added PHP 7.2 support
    • Upgraded nette/utils to version 2.5
  • v0.4.0 Released version 0.4.0

    • Fixed compatibility with Nette 2.4
    • Dropped PHP 5.5 support
  • v0.3.0 Released version 0.3.0

    • Fixed Time parsing when hour part is missing
    • Added testing on PHP 7.1
  • v0.2.1 Released version 0.2.1

    • Fixed time part generation in methods firstDayOfWeek() and lastDayOfWeek()
  • v0.2.0 Released version 0.2.0

    • Added class Time for time parsing (see test for usage)
    • DateTime: added function for getting first and last day of week
    • DateTime: Fixed interval generation for other intervals than month
  • v0.1.0 Released version 0.1.0

    First release.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com