Git Product home page Git Product logo

Comments (4)

xuwei-k avatar xuwei-k commented on July 19, 2024

https://github.com/nscala-time/nscala-time/blob/releases/2.10.0/src/main/scala/com/github/nscala_time/time/RichDuration.scala

Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.github.nscala_time.time.Implicits._
import com.github.nscala_time.time.Implicits._

scala> new org.joda.time.Interval(0, 1)
res0: org.joda.time.Interval = 1970-01-01T09:00:00.000+09:00/1970-01-01T09:00:00.001+09:00

scala> res0.toDuration.toScalaDuration
res1: scala.concurrent.duration.Duration = 1 millisecond

from nscala-time.

acjay avatar acjay commented on July 19, 2024

That doesn't quite get me there, as the API I'm trying to use requires FiniteDuration.

Right now, I'm using time => (DateTime.now() to time).toDurationMillis.millis, with import scala.concurrent.duration._ to get the unit methods. It feels like there should be a way to just drop in the interval I want where w FiniteDuration is expected. Would it be undesirable for this implicit conversion to exist?

from nscala-time.

tkawachi avatar tkawachi commented on July 19, 2024

toScalaDuration will return FiniteDuration since the next version. https://github.com/nscala-time/nscala-time/pull/106/files
Is it sufficient for you?

from nscala-time.

acjay avatar acjay commented on July 19, 2024

That helps out, but it would be useful to have that on Interval too. With toScalaDuration, it still looks like time => (DateTime.now() to time).toDuration.toScalaDuration, which seems overly verbose for what it's trying to accomplish.

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.