Code Monkey home page Code Monkey logo

Comments (4)

Pauan avatar Pauan commented on May 13, 2024 2

Is there any reason this can't be added to chrono? Have they rejected the idea of having a web submodule which is enabled by a feature?

from seed.

David-OConnor avatar David-OConnor commented on May 13, 2024 1

That might be the best approach. Not rejected, but there's a related issue and PR that's been idle for a bit. Worth pursuing this route.

I'm still concerned about the verbosity of the api; ie I don't want users to have to write code like this wrapper:

    /// Convert an iso-format date, eg "2019-01-05" for January 5, 2019" to a Date.
    pub fn from_iso(date: &str) -> Self {
        // Chrono needs time too; and can't parse date-only directly.
        let padded = &(date.to_string() + "T000000");
        Self {
            wrapped: chrono::Utc
                .datetime_from_str(padded, "%Y-%m-%dT%H%M%S")
                .expect(&format!("Can't format date: {}", date))
                .date()
        }
    }

Although this could also be a PR for Chrono.

from seed.

Pauan avatar Pauan commented on May 13, 2024

I would expect a function called from_iso to fully support all of ISO, not just dates. So that seems like an ad-hoc function specialized to a particular app's needs.

Aside from that, is chrono::DateTime::parse_from_rfc3339(date).unwrap_throw().date() too verbose? It seems pretty straightforward to me, personally.

And similarly, a chrono::Date::parse_from_rfc3339(date).unwrap_throw() could be used for date only (though that needs a PR to add it to chrono).

from seed.

David-OConnor avatar David-OConnor commented on May 13, 2024

Closing this for now - until I find the scope of limitations of Chrono in WASM, and pursue PRs there.

from seed.

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.