Giter Site home page Giter Site logo

Comments (4)

wookietreiber avatar wookietreiber commented on July 21, 2024 1

Ah, OK, now I get it: period.millis returns the milliseconds part of the period, while duration.millis returns the duration in milliseconds (I just had to check the joda time API docs, because I was confused). So, 1.day.millis === 0 is in fact correct.

I wonder, what could be done to make this not as confusing as it is right now to users. The DSL should definitely make it clear whether you get a duration or a period, while the user still has to figure out the exact differences between the two for herself/himself.

// compiles
1.period.day
24.duration.hours

// does not compile
1.duration.day

This would help although it feels a bit more clumsy. I guess, tradeoff between concise DSL vs. clearer DSL.

I vote to change the DSL because the issue not only entails user confusion but even erroneous apps / libs because of the wrong assumption that 1.day.millis != 0.

from nscala-time.

kmizu avatar kmizu commented on July 21, 2024

Hi.

The above behavior is confusable. But I think it's intended behavior. See below:
https://github.com/nscala-time/nscala-time/blob/releases/1.8.0/src/main/scala/com/github/nscala_time/time/RichInt.scala#L34-L41

from nscala-time.

wookietreiber avatar wookietreiber commented on July 21, 2024

But 1.day.millis === 0 can't be correct, can it?

I guess, whether this behaviour is intended or not, it should be in a Spec-like test somewhere (don't know if it already is) so people can see the expected behaviour.

from nscala-time.

gakuzzzz avatar gakuzzzz commented on July 21, 2024

I agree that 1.day.millis === 0 is confusable.

Essentially problem is there is no way of representing day, week, month, year and etc to Duration.

We should provide another DSL what builds Period and Duration explicitly.

from nscala-time.

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.