Componette

Componette

sunfoxcz

sunfoxcz / date-utils v3.0.0-alpha1

Library for easier working with date intervals.

download-cloud-line composer require sunfoxcz/date-utils

DateUtils library

Library for easier working with date intervals.

Installation

composer require sunfoxcz/date-utils

Usage

DateIntervalFactory

<?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.

  • v3.0.0-alpha1 Released version 3.0.0-alpha1

    • Dropped dependency on nette/utils and merged parent methods as they were in v3.2.2 [BC break]
    • DateTime: extends \DateTimeImmutable instead of \DateTime [BC break]
    • Method modifyClone() was removed, use modify() instead [BC break]
    • DateTime: method __construct() is now final [BC break]
    • Minimal supported PHP version is now 7.4
    • Added PHP 8.0 support
  • v2.0.0 Released version 2.0.0

    • DateTime: use \DateTimeInterface instead of \DateTime [BC break]
    • DateTime: moved method createInterval() to separate class DateIntervalFactory [BC break]
    • DateTime: removed public property $quarters [BC break]
    • DateTime: updated firstDayOfYear() and lastDayOfYear() methods to use \DateTimeInterface as parameters to be consistent with other methods [BC break]*
    • Dropped PHP 7.1 support
  • v1.1.2 Released version 1.1.2

    • Fixed bug in SpentTime::add() method
  • v1.1.1 Released version 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.

bar-chart-fill

Statistics

download-cloud-fill
3923
star-fill
0
bug-fill
0
flashlight-fill
218d
price-tag-2-line

Badges

guide-fill

Dependencies

php (^7.1)
nette/utils (^2.5 || ^3.0)
Componette Componette felix@nette.org