Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic conversion to scala.concurrent.duration #54

Closed
kepkin opened this issue Apr 5, 2014 · 9 comments
Closed

Automatic conversion to scala.concurrent.duration #54

kepkin opened this issue Apr 5, 2014 · 9 comments

Comments

@kepkin
Copy link

kepkin commented Apr 5, 2014

Hi!

I'm using nscala-time with RxScala, so I had to write a simple implicit conversion:

import com.github.nscala_time.time.Imports.{ Duration => NscalaDuration }
import scala.concurrent.duration._

object NscalaDurationImplicits {
   implicit def Dur2Dur(d: NscalaDuration) : Duration = d.getStandardSeconds() seconds 
}

I think it's possible to include this conversion into nscala-time

@kepkin
Copy link
Author

kepkin commented Apr 6, 2014

Oh I was terribly wrong!
When I write

val x = 3 seconds // type inference says it's a com.github.nscala_time.time.DurationBuilder

So I need an implicit conversion from DurationBuilder, but it's a private class! So the following just won't compile

package implicit_vs_private

import scala.concurrent.duration.{Duration => ScalaDuration}
import com.github.nscala_time.time.Imports._
import com.github.nscala_time.time.DurationBuilder

object Test {
  implicit def NscalaDurationBuilder2Duration(x: DurationBuilder) : ScalaDuration = ScalaDuration.fromNanos(x.standardDuration.getMillis * 1000000)
}

@kmizu
Copy link

kmizu commented Apr 7, 2014

Hi. There are another request to make DurationBuilder public already. Whether we accept your proposal, to implicit converion to nscala-time, or not, I'd like to make DurationBuilder public. Since DurationBuilder is mostly internal representation, it's not so good to make it public, but I'd like to do it for convenience.

What do you think? /cc: @gakuzzzz @xuwei-k @tototoshi

@gakuzzzz
Copy link
Member

gakuzzzz commented Apr 8, 2014

I'm your side, @kmizu. I's not so good to make it public
However, we dont have more better solution... mmm

@kmizu
Copy link

kmizu commented May 17, 2014

Today, I decided to make DurationBuilder public since another elegant solution could not be found.
I'll create the PR to do it.

@kmizu
Copy link

kmizu commented May 23, 2014

Fixed via #64

@kmizu kmizu closed this as completed May 23, 2014
@yokomizor
Copy link

What you think about to include @kepkin conversion's into nscala-time?

I think it would be very useful.

@kmizu
Copy link

kmizu commented Jul 19, 2014

@yokomizor OK. I think it's a good idea to add @kepkin conversion's into nscala-time. Since I'm a little busy, it helps us if you create the PR to add @kepkin conversion's into nscala-time. Or please wait a while for creating the PR.

@kmizu kmizu reopened this Jul 19, 2014
@kmizu
Copy link

kmizu commented Jul 19, 2014

@yokomizor Note that Since nscala-time is simple sbt project, I think that you can edit nscala-time code easily via text editors or IDEs (Especially, IntelliJ IDEA + Scala Plugin).

@kmizu
Copy link

kmizu commented Jul 23, 2014

@yokomizor I'm sorry to late response. After I create the PR #69 and the PR's badness is point outed, I found it bad idea that @kepkin conversions are included into nscala-time. Then, I close this issue.

@kmizu kmizu closed this as completed Jul 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants