bug? MappedDate toLong return seconds but not milliseconds?

28 views
Skip to first unread message

wm

unread,
Nov 18, 2012, 11:41:55 PM11/18/12
to Lift
http://main.scala-tools.org/mvnsites/liftweb-2.0/framework/scaladocs/net/liftweb/mapper/MappedDate.scala.html#Some(42)

line 68 ~ 71:

def toLong: Long = is match {
case null => 0L
case d: Date => d.getTime / 1000L
}

Elsewhere it all use millis,

And the constructor of

java.util.Date(long date) also take millis, so why toLong take the
extra step to return seconds?

David Pollak

unread,
Nov 19, 2012, 12:36:17 PM11/19/12
to lif...@googlegroups.com
Probably not a bug. I probably had a rational reason for doing this back when I did it (please do a git blame to see who wrote the code).

In an ideal world, we'd change it. But it would also introduce a silent change that might break software.

I'd suggest opening a ticket to deprecate the method and in a version or two, we'll remove it, then introduce a method that does the right thing.


--
--
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






--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net


wm

unread,
Nov 19, 2012, 7:10:51 PM11/19/12
to Lift
Then at least write in the doc, it returns seconds instead of millis.

So user don't have to go to the code to find the problem.

I think in Java, user will naturally think long holds millis, esp.
because of the java.util.Date(long date) ctor.

On Nov 19, 9:36 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Probably not a bug. I probably had a rational reason for doing this back
> when I did it (please do a git blame to see who wrote the code).
>
> In an ideal world, we'd change it. But it would also introduce a silent
> change that might break software.
>
> I'd suggest opening a ticket to deprecate the method and in a version or
> two, we'll remove it, then introduce a method that does the right thing.
>
>
>
>
>
>
>
>
>
> On Sun, Nov 18, 2012 at 8:41 PM, wm <min...@gmail.com> wrote:
>
> >http://main.scala-tools.org/mvnsites/liftweb-2.0/framework/scaladocs/...)
>
> > line 68 ~ 71:
>
> >   def toLong: Long = is match {
> >     case null => 0L
> >     case d: Date => d.getTime / 1000L
> >   }
>
> > Elsewhere it all use millis,
>
> > And the constructor of
>
> > java.util.Date(long date) also take millis, so why toLong take the
> > extra step to return seconds?
>
> > --
> > --
> > 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
>
> --
> Telegram, Simply Beautiful CMShttps://telegr.am
> Lift, the simply functional web frameworkhttp://liftweb.net

Naftoli Gugenheim

unread,
Nov 20, 2012, 3:09:46 AM11/20/12
to liftweb
On Mon, Nov 19, 2012 at 7:10 PM, wm <min...@gmail.com> wrote:
Then at least write in the doc, it returns seconds instead of millis.

Feel free to open a pull request with the documentation improvement. It would be great if you could.

Dave Briccetti

unread,
Nov 20, 2012, 4:53:37 AM11/20/12
to lif...@googlegroups.com
I’ll add a doc comment now.
Reply all
Reply to author
Forward
0 new messages