now that parts of TimeSpan is deprecated, what do I use?

34 views
Skip to first unread message

Diego Medina

unread,
Feb 7, 2015, 6:47:58 PM2/7/15
to Lift
Hi,

In Lift we now have this warning: (we actually have several related warnings)

 method intToTimeSpan in trait TimeHelpers is deprecated: Int to TimeSpan conversion will be removed for possibility of ambiguous behaviours
[warn]         LAPinger.schedule(this, BreakOut(), 5.millis)
[warn]                                                                     ^


calling 5.millis or 10.seconds was pretty common before, what should we use now?

Thanks


--
Diego Medina
Lift/Scala consultant
di...@fmpwizard.com
http://fmpwizard.telegr.am

Arkadiusz Burdach

unread,
Feb 8, 2015, 4:00:22 AM2/8/15
to lif...@googlegroups.com
Hi.

There is no problem with 5.millis construction but with with LAPinger.schedule method which takes a Long (millis) instead of TimeSpan. It will be better to standarize methods taking duration that they will explicitly take TimeSpan.

Arek

Alexandre Richonnier

unread,
Feb 8, 2015, 5:09:46 PM2/8/15
to lif...@googlegroups.com
Hi,

Now I use
"com.github.nscala-time"    %% "nscala-time"              % "1.6.0",

A new Scala wrapper for Joda Time compatible with scala 2.11.x

No more problems and dependances with lift.

Antonio Salazar Cardozo

unread,
Feb 8, 2015, 9:19:28 PM2/8/15
to lif...@googlegroups.com
Interesting… I've been rolling the idea in my head of scala durations vs Joda durations… If
there's a nice DSL for Joda durations that's already a core thing that we deal with in Lift, but
on the flip side Scala durations are part of the language we're built on as well... Decisions
decisions.

More noodling needed for my part. Thanks for the pointer to nscala-time!
Antonio

Antonio Salazar Cardozo

unread,
Feb 8, 2015, 9:20:48 PM2/8/15
to lif...@googlegroups.com
Interesting note:
// returns com.github.nscala_time.time.DurationBuilder
// (can be used as a Duration or as a Period)
I wonder if they dealt with the pitfalls that can yield…
Thanks,
Antonio

Diego Medina

unread,
Feb 14, 2015, 11:40:23 PM2/14/15
to Lift
ok, so the original warning went away when I simply used a Long, now I have another issue :) :


[info] Compiling 1 Scala source to /home/diego/work/lift/framework/web/webkit/target/scala-2.11/classes...
[warn] /home/diego/work/lift/framework/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala:112: method longToTimeSpan in trait TimeHelpers is deprecated: Long to TimeSpan conversion will be removed for possibility of ambiguous behaviours
[warn]       }, 5.millis)
[warn]            ^
[warn] /home/diego/work/lift/framework/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala:112: method intToTimeSpan in trait TimeHelpers is deprecated: Int to TimeSpan conversion will be removed for possibility of ambiguous behaviours
[warn]       }, 5.millis)
[warn]          ^
[warn] two warnings found


now, if I read this right, we are calling schedule from here:


which expects a TimeSpan

why the warning here? and what's the expected way to solve it?

Thanks




--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arkadiusz Burdach

unread,
Feb 15, 2015, 5:47:59 AM2/15/15
to lif...@googlegroups.com
It looks like we are using other method for building TimeSpan using .millis than .seconds/.minutes/.hours

For .seconds/.minutes/.hours we have implicit class TimeSpanBuilder with methods returning TimeSpan
In contrary .millis uses:
implicit conversion from int/long to TimeSpan -> TimeSpan.millis returns Long -> long is converted to TimeSpan second time

I've tried to add simillar .millis builder in TimeSpanBuilder to resolve this network but it causes:

[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method intToTimeSpanBuilder in trait TimeHelpers of type (in: Int)net.liftweb.util.Helpers.TimeSpanBuilder
[error]  and method intToTimeSpan in trait TimeHelpers of type (in: Int)net.liftweb.util.Helpers.TimeSpan
[error]  are possible conversion functions from Int(5) to ?{def millis: ?}

For now it looks like the only one way to skip warnings is to explicitly use TimeSpan(Int). In future releases we could remove deprecated conversions and add next .millis builder.

Any other ideas?

Arek

Antonio Salazar Cardozo

unread,
Feb 15, 2015, 9:15:31 AM2/15/15
to lif...@googlegroups.com
How about we add a quick note to the deprecation warning on int-to-timestamp for this
case (e.g., “If you see this warning for e.g. 5.millis, use TimeSpan(5) instead.”)?
Thanks,
Antonio

Arek Burdach

unread,
Feb 15, 2015, 9:19:48 AM2/15/15
to lif...@googlegroups.com
It seems to be a helpful tip.

Arek

W dniu 15.02.2015 o 15:15, Antonio Salazar Cardozo pisze:

Diego Medina

unread,
Feb 15, 2015, 10:49:04 AM2/15/15
to Lift
sounds good, I can change the deprecated message as part of the changes I'm doing, should be able to send a pr late tonight

Thanks!
Reply all
Reply to author
Forward
0 new messages