Giter Site home page Giter Site logo

Comments (5)

TristonianJones avatar TristonianJones commented on July 29, 2024 1

I'm sorry we didn't get back to you on this sooner. The duration format we support within Go, unofficially, is what time.ParseDuration supports: https://golang.org/src/time/format.go?s=40605:40651#L1364

This PR is about making sure the spec and other implementations support the same logic as Go since it seems to be the maximum about of usability with the least amount of confusion.

As for type conversions, we don't make any assumptions about units and offer timestamp + duration overloads, but no overload for duration + int as it's not clear what the intent is of the unit-less number. I don't think it's a super common use case to add two duration values constructed from string inputs, but I could be wrong. The preferred technique would be: duration("2h30m45s") + duration("2s") == duration("8456s")

from cel-spec.

slott56 avatar slott56 commented on July 29, 2024

Are these normalized in any way when a duration is the output from the expression? Would a trivial expression like duration("2h30m45s") output duration("8454s")? Would we need timestamp-like extractor methods for days and weeks? double(duration("8454s").days()) == 0.097847?

Also. What about type conversions? Would these have an assumed unit? duration("2h30m45s") + 2 == duration("8456s") Or would there be no overload for this?

from cel-spec.

jsannemo avatar jsannemo commented on July 29, 2024

This would be very nice to have, and the option of `duration("2h30m45s") over adding each unit separately seems nicer. Both cel-go and cel-cpp supports this, so one might just as well formalize it.

Also, I believe fractional seconds are allowed in both cel-go and cel-cpp (cel-cpp seems to use absl::ParseDuration which afaict is essentially the same logic as time.ParseDuration), but it is not clear that this is the case in the spec.

from cel-spec.

JimLarson avatar JimLarson commented on July 29, 2024

The go syntax seems like a reasonable standard to follow. There doesn't seem to be a standard duration notation in Google SQL or Javascript - the prototype languages we try to follow. There's an ISO-8601 notation for durations, but it's clunky and and not compatible with the current "120s" notation.

from cel-spec.

TristonianJones avatar TristonianJones commented on July 29, 2024

A common subset of the duration parsing syntax supported by Go (native), Java (threeten-extra), and C++ (abseil.io) has been introduced in all of the runtimes, and the spec now clarifies the supported notation and character set. Days is not supported, but more granular units are. See #185

from cel-spec.

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.