Giter Club home page Giter Club logo

doctrine-utc-date-time's Introduction

Doctrine UTC Date Time На Русском

PHPUnit Coverage Status Latest Stable Version Total Downloads

Introduction

Component contains DBAL types for date and time and can be registered as Doctrine types. DBAL types provides functionality for storing date and time into database in the UTC. List of the available types:

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this component:

    composer require adrenalinkin/doctrine-utc-date-time

This command requires you to have Composer install globally.

Usage

For registration new Doctrine type use official instruction How to Use Doctrine DBAL.

For registration new separate UTC types:

# app/config/config.yml
doctrine:
    dbal:
        types:
            utc_date:     Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType
            utc_datetime: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateTimeType
            utc_time:     Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcTimeType

Also, you can overwrite standard types:

# app/config/config.yml
doctrine:
    dbal:
        types:
            date:     Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType
            datetime: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateTimeType
            time:     Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcTimeType

License

license

doctrine-utc-date-time's People

Contributors

adrenalinkin avatar dharple avatar pavelkirpitsov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

doctrine-utc-date-time's Issues

TypeError in PHP 8.1 Caused by Datetime::Createfromformat() Returning False

We ran into the following exception.

Uncaught TypeError: Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateTimeType::convertToPHPValue(): Return value must be of type ?DateTimeInterface, bool returned in /srv/....

According to the PHP documentation, DateTime::createFromFormat() can return false, which conflicts with the specified return type.

Deprecation warnings with latest doctrine bundle

Doctrine first moans about not having 'commented: true' in the config. If that is set, it then says:

php.INFO: User Deprecated: The type "date" was marked as commented in its configuration but not in the type itself. This is deprecated and will be removed in DoctrineBundle 2.0. Please update the return value of "Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType::requiresSQLCommentHint()." {"exception":"[object] (ErrorException(code: 0): User Deprecated: The type "date" was marked as commented in its configuration but not in the type itself. This is deprecated and will be removed in DoctrineBundle 2.0. Please update the return value of "Linkin\Component\DoctrineUTCDateTime\DBAL\Types\UtcDateType::requiresSQLCommentHint()." at .../vendor/doctrine/doctrine-bundle/ConnectionFactory.php:140)"} []

I think, the three type classes should add method requiresSQLCommentHint() and return true to get rid of that deprecation warning. After that, 'commented: true' in config can be removed again, and the deprecation is gone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.