Coder Social home page Coder Social logo

Comments (12)

scrubmx avatar scrubmx commented on May 3, 2024 2

I have a trait that I use in my BaseModel class:

<?php

namespace App\Models\Traits;

use Jenssegers\Date\Date;

trait TranslatesDates
{
    /**
     * Return model date attributes as a Jenssegers\Date\Date instance.
     *
     * @override \Illuminate\Database\Eloquent\Model
     *
     * @param mixed $value
     * 
     * @return \Jenssegers\Date\Date
     */
    protected function asDateTime($value)
    {
        return new Date(parent::asDateTime($value));
    }
}

As far as I know is the easiest way.

from ideas.

AdenFraser avatar AdenFraser commented on May 3, 2024 1

@rtconner Surely providing the opportunity to remove an 'already high memory' date/time handler would be beneficial, if you see it as such a problem?

from ideas.

IsraelOrtuno avatar IsraelOrtuno commented on May 3, 2024

Carbon already supports localization http://carbon.nesbot.com/docs/#api-localization

from ideas.

AdenFraser avatar AdenFraser commented on May 3, 2024

I was under the impression that only worked with the Localization that was built into the package? I'm not sure if there are locales missing, but you certainly wouldn't be in a situation where you can adjust the strings for diffForHumans I'd expect?

from ideas.

IsraelOrtuno avatar IsraelOrtuno commented on May 3, 2024

I think you could set a Translator instance manually to Carbon but actually you are right, Carbon is not very opened to changes

from ideas.

Mevrael avatar Mevrael commented on May 3, 2024

Not a fan of Carbon but had no problems using it, however I agree it's, in times, complicated and should be bindable/injectable/replacable.

from ideas.

AdenFraser avatar AdenFraser commented on May 3, 2024

I actually like Carbon a lot but there are instances where it would be nice to be able to extend / replace it for different purposes, but it seems baked pretty tightly, especially with Eloquent which is where you are most likely to be want to extend it I imagine.

from ideas.

rtconner avatar rtconner commented on May 3, 2024

Man this just seems like it would make an already high memory date/time handling even bulkier.

from ideas.

AdenFraser avatar AdenFraser commented on May 3, 2024

@taylorotwell What are your thoughts in regards to this?

If it's something that you think is a feasible improvement to the core, I'll set about putting together a PR.

from ideas.

Jeroen-G avatar Jeroen-G commented on May 3, 2024

See also this: https://hashnode.com/ama/with-taylor-otwell-cilmj90zh000k6t53il0rdgqp#cilx5el0u00m3gb53xbey9i1o

from ideas.

AdenFraser avatar AdenFraser commented on May 3, 2024

Interesting @Jeroen-G, I shall start putting together a PR then

from ideas.

taylorotwell avatar taylorotwell commented on May 3, 2024

Carbon has new maintainers now which may improve the quality / maintenance of the library going forward.

from ideas.

Related Issues (20)

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.