2017 © Pedro Peláez
 

symfony-bundle datetime-bundle

Symfony bundle for handling the PHP DateTime functionalities

image

budgegeria/datetime-bundle

Symfony bundle for handling the PHP DateTime functionalities

  • Tuesday, March 24, 2015
  • by SenseException
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

BudgegeriaDatetimeBundle

Build Status SensioLabsInsight, (*1)

Symfony bundle for handling the PHP DateTime functionalities., (*2)

Handling DateTime functionality for getting current date and time values can be sometimes a bit tricky in Symfony, especially when it comes to unittests. This bundle provides helper, services and configuration for datetime of a project., (*3)

Installation

This Bundle has PHP 5.5 as minimum requirement. Add the following package to your composer.json, (*4)

"require": {
    "budgegeria/datetime-bundle": "0.1"
}

and add the bundle to your AppKernel.php, (*5)

// app/AppKernel.php
//...
class AppKernel extends Kernel
{
    //...
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Budgegeria\Bundle\DatetimeBundle\BudgegeriaDatetimeBundle(),
        );
        //...

        return $bundles;
    }
    //...
}

Configuration

At the moment, only the timezone can be configured. With this, every datetime service will use this timezone as default., (*6)

budgegeria_datetime:
    timezone: UTC

Services

If you have or need to create a service, that depends on DateTime, you don't want to create that object directly in your classes, because you want the current time. Injecting the DateTime object with a setter or over a constructor results in a time difference in case you want exactly the date and time when you access the object. The DatetimeBundle provides services for that., (*7)

DateTime

All DateTime services are returning the current time and the timezone from the configuration, (*8)

Lazy Loading

budgegeria_datetime.datetime - This prototype service provides a lazy loading wrapper for DateTime which returns always a new instance on service access. The actual DateTime object will be lazily created on first access on one of its methods, so you can decide yourself when the current time should be fetched. Since this is a injectable service, this can make your unit tests easy-peasy., (*9)

Immutable

budgegeria_datetime.datetime_immutable - The same like budgegeria_datetime.datetime, but using DateTimeImmutable instead of DateTime., (*10)

Global

budgegeria_datetime.datetime_global - The default service behaviour of Symfony can be used with this service. The time doesn't change from its first object creation through the whole execution of the request., (*11)

Timezone

budgegeria_datetime.timezone - Returns a DateTimeZone object containing the configured timezone., (*12)

The Versions

24/03 2015

dev-master

9999999-dev

Symfony bundle for handling the PHP DateTime functionalities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Claudio Zizza

date time datetime intl dateformatter

24/03 2015

0.1

0.1.0.0

Symfony bundle for handling the PHP DateTime functionalities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Claudio Zizza

date time datetime intl dateformatter