[groovy-dev] Overloaded Date plus operator

classic Classic list List threaded Threaded
26 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[groovy-dev] Overloaded Date plus operator

graemer
Saw an interesting post by Jeff Brown about the behaviour of the
overloaded date operator when using java.sql.Date:
http://javajeff.blogspot.com/2006/05/operator-overloading-in-groovy.html

Is this a bug? Should this return a sql date when using the sql date class?

Graeme

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: [groovy-dev] Overloaded Date plus operator

Dierk König
I'd say is a missing plus() method on java.sql.Date.

cheers
Mittie

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Mittwoch, 31. Mai 2006 15:05
> To: [hidden email]
> Subject: [groovy-dev] Overloaded Date plus operator
>
>
> Saw an interesting post by Jeff Brown about the behaviour of the
> overloaded date operator when using java.sql.Date:
> http://javajeff.blogspot.com/2006/05/operator-overloading-in-groovy.html
>
> Is this a bug? Should this return a sql date when using the sql
> date class?
>
> Graeme
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

tugwilson
In reply to this post by graemer

On 31 May 2006, at 14:04, Graeme Rocher wrote:

> Saw an interesting post by Jeff Brown about the behaviour of the
> overloaded date operator when using java.sql.Date:
> http://javajeff.blogspot.com/2006/05/operator-overloading-in- 
> groovy.html
>
> Is this a bug? Should this return a sql date when using the sql  
> date class?


This could be done by adding plus/minus methods taking  
(java.sql.Date, int) in DGM.

At the moment we are calling the methods which take (java.util.Date,  
int), as java.sql.Date is a subclass of java.sql.Date.

I think it would be worth doing this. Especially as we plan to add  
the work I have been doing on Duration arithmetic (which is sitting  
in the GData package at the moment). Once you start to do proper  
Duration arithmetic then the distinction between java.util.Date and  
java,sql.Date becomes important.

Would you like to raise a JIRA issue for this?


John Wilson
The Wilson Partnership
web http://www.wilson.co.uk
blog http://eek.ook.org



---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

graemer
Done: http://jira.codehaus.org/browse/GROOVY-1331

When is that duration stuff going into Groovy core, I can't wait :-)

Graeme

On 5/31/06, John Wilson <[hidden email]> wrote:

>
> On 31 May 2006, at 14:04, Graeme Rocher wrote:
>
> > Saw an interesting post by Jeff Brown about the behaviour of the
> > overloaded date operator when using java.sql.Date:
> > http://javajeff.blogspot.com/2006/05/operator-overloading-in-
> > groovy.html
> >
> > Is this a bug? Should this return a sql date when using the sql
> > date class?
>
>
> This could be done by adding plus/minus methods taking
> (java.sql.Date, int) in DGM.
>
> At the moment we are calling the methods which take (java.util.Date,
> int), as java.sql.Date is a subclass of java.sql.Date.
>
> I think it would be worth doing this. Especially as we plan to add
> the work I have been doing on Duration arithmetic (which is sitting
> in the GData package at the moment). Once you start to do proper
> Duration arithmetic then the distinction between java.util.Date and
> java,sql.Date becomes important.
>
> Would you like to raise a JIRA issue for this?
>
>
> John Wilson
> The Wilson Partnership
> web http://www.wilson.co.uk
> blog http://eek.ook.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

Steven Devijver
I've got some code laying around that I'm willing to donate.

It's got a Duration class but also an Interval class. Interval
arithmetic is different from Duration since it's limit-based. Interval
is ideal for working with periods. You can create an Interval from an
Instant (or Timestamp or Calendar or Date) and a Duration.

Next you can compare this Interval with another Interval and get new
Interval objects for the overlapping and non-overlapping parts.

Steven

On 5/31/06, Graeme Rocher <[hidden email]> wrote:

> Done: http://jira.codehaus.org/browse/GROOVY-1331
>
> When is that duration stuff going into Groovy core, I can't wait :-)
>
> Graeme
>
> On 5/31/06, John Wilson <[hidden email]> wrote:
> >
> > On 31 May 2006, at 14:04, Graeme Rocher wrote:
> >
> > > Saw an interesting post by Jeff Brown about the behaviour of the
> > > overloaded date operator when using java.sql.Date:
> > > http://javajeff.blogspot.com/2006/05/operator-overloading-in-
> > > groovy.html
> > >
> > > Is this a bug? Should this return a sql date when using the sql
> > > date class?
> >
> >
> > This could be done by adding plus/minus methods taking
> > (java.sql.Date, int) in DGM.
> >
> > At the moment we are calling the methods which take (java.util.Date,
> > int), as java.sql.Date is a subclass of java.sql.Date.
> >
> > I think it would be worth doing this. Especially as we plan to add
> > the work I have been doing on Duration arithmetic (which is sitting
> > in the GData package at the moment). Once you start to do proper
> > Duration arithmetic then the distinction between java.util.Date and
> > java,sql.Date becomes important.
> >
> > Would you like to raise a JIRA issue for this?
> >
> >
> > John Wilson
> > The Wilson Partnership
> > web http://www.wilson.co.uk
> > blog http://eek.ook.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

tugwilson
In reply to this post by graemer

On 31 May 2006, at 14:41, Graeme Rocher wrote:

> Done: http://jira.codehaus.org/browse/GROOVY-1331
>
> When is that duration stuff going into Groovy core, I can't wait :-)

We need general agreement from the team and I need to do some more  
Unit tests (and now, support java.sql.Date which I'd forgotten  
about). Not much work if the team agrees it's a good thing to have:)

John Wilson
The Wilson Partnership
web http://www.wilson.co.uk
blog http://eek.ook.org



---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

tugwilson
In reply to this post by Steven Devijver

On 31 May 2006, at 14:49, Steven Devijver wrote:

> 've got some code laying around that I'm willing to donate.
>
> It's got a Duration class but also an Interval class. Interval
> arithmetic is different from Duration since it's limit-based. Interval
> is ideal for working with periods. You can create an Interval from an
> Instant (or Timestamp or Calendar or Date) and a Duration.
>
> Next you can compare this Interval with another Interval and get new
> Interval objects for the overlapping and non-overlapping parts.


Stephen,

have a look at what I have done so far (It's in the GData package.  
The demo.groovy program gives you some idea how it works). Can we add  
some or all of your stuff to this?


John Wilson
The Wilson Partnership
web http://www.wilson.co.uk
blog http://eek.ook.org



---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: [groovy-dev] Overloaded Date plus operator

Dierk König
In reply to this post by tugwilson
I'm a bit reluctant to put this into Groovy-1.0.

I see the value and I also find it cool, of course.

But then, I have to cover it in the book ;-)

No, honestly, I'd like to see how that fits into
idiomatic Groovy that uses Date ranges etc.
Will sleep() need to work with durations? How about
Timer and TimerTask?
There already is some uneasy relationship between
lists and ranges. Having new interval and duration abstractions
will make things even more complicated.

We should give it a bit of time to develop in
the module before promoting it to the core.

What I would support 100% is a facility that eases
installation of modules.

cheers
Mittie

> -----Original Message-----
> From: John Wilson [mailto:[hidden email]]
> Sent: Mittwoch, 31. Mai 2006 15:52
> To: [hidden email]
> Subject: Re: [groovy-dev] Overloaded Date plus operator
>
>
>
> On 31 May 2006, at 14:41, Graeme Rocher wrote:
>
> > Done: http://jira.codehaus.org/browse/GROOVY-1331
> >
> > When is that duration stuff going into Groovy core, I can't wait :-)
>
> We need general agreement from the team and I need to do some more  
> Unit tests (and now, support java.sql.Date which I'd forgotten  
> about). Not much work if the team agrees it's a good thing to have:)
>
> John Wilson
> The Wilson Partnership
> web http://www.wilson.co.uk
> blog http://eek.ook.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

graemer
On 5/31/06, Dierk Koenig <[hidden email]> wrote:
> I'm a bit reluctant to put this into Groovy-1.0.
>
> I see the value and I also find it cool, of course.
>
> But then, I have to cover it in the book ;-)
>
> No, honestly, I'd like to see how that fits into
> idiomatic Groovy that uses Date ranges etc.
> Will sleep() need to work with durations?
Thread.sleep( 5.minutes )

How about
> Timer and TimerTask?
def t = new Timer()
t.schedule( new MyTimerTask(), 2.days.from.now, 5.minutes )

> There already is some uneasy relationship between
> lists and ranges. Having new interval and duration abstractions
> will make things even more complicated.
Ruby has them, its not necessarily an abstraction, but a more natural
way to specific durations.

>
> We should give it a bit of time to develop in
> the module before promoting it to the core.
Yes I understand why, would be very handy for Grails' job scheduling though

Graeme

>
> What I would support 100% is a facility that eases
> installation of modules.
>
> cheers
> Mittie
>
> > -----Original Message-----
> > From: John Wilson [mailto:[hidden email]]
> > Sent: Mittwoch, 31. Mai 2006 15:52
> > To: [hidden email]
> > Subject: Re: [groovy-dev] Overloaded Date plus operator
> >
> >
> >
> > On 31 May 2006, at 14:41, Graeme Rocher wrote:
> >
> > > Done: http://jira.codehaus.org/browse/GROOVY-1331
> > >
> > > When is that duration stuff going into Groovy core, I can't wait :-)
> >
> > We need general agreement from the team and I need to do some more
> > Unit tests (and now, support java.sql.Date which I'd forgotten
> > about). Not much work if the team agrees it's a good thing to have:)
> >
> > John Wilson
> > The Wilson Partnership
> > web http://www.wilson.co.uk
> > blog http://eek.ook.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: [groovy-dev] Overloaded Date plus operator

Steven Devijver
On 5/31/06, Graeme Rocher <[hidden email]> wrote:

> On 5/31/06, Dierk Koenig <[hidden email]> wrote:
> > I'm a bit reluctant to put this into Groovy-1.0.
> >
> > I see the value and I also find it cool, of course.
> >
> > But then, I have to cover it in the book ;-)
> >
> > No, honestly, I'd like to see how that fits into
> > idiomatic Groovy that uses Date ranges etc.
> > Will sleep() need to work with durations?
> Thread.sleep( 5.minutes )
>
> How about
> > Timer and TimerTask?
> def t = new Timer()
> t.schedule( new MyTimerTask(), 2.days.from.now, 5.minutes )
>
> > There already is some uneasy relationship between
> > lists and ranges. Having new interval and duration abstractions
> > will make things even more complicated.
> Ruby has them, its not necessarily an abstraction, but a more natural
> way to specific durations.
>
> >
> > We should give it a bit of time to develop in
> > the module before promoting it to the core.
> Yes I understand why, would be very handy for Grails' job scheduling though

Based on the current abstraction for registering properties and
methods we can add this to Grails via a plugin.

Steven

>
> Graeme
>
> >
> > What I would support 100% is a facility that eases
> > installation of modules.
> >
> > cheers
> > Mittie
> >
> > > -----Original Message-----
> > > From: John Wilson [mailto:[hidden email]]
> > > Sent: Mittwoch, 31. Mai 2006 15:52
> > > To: [hidden email]
> > > Subject: Re: [groovy-dev] Overloaded Date plus operator
> > >
> > >
> > >
> > > On 31 May 2006, at 14:41, Graeme Rocher wrote:
> > >
> > > > Done: http://jira.codehaus.org/browse/GROOVY-1331
> > > >
> > > > When is that duration stuff going into Groovy core, I can't wait :-)
> > >
> > > We need general agreement from the team and I need to do some more
> > > Unit tests (and now, support java.sql.Date which I'd forgotten
> > > about). Not much work if the team agrees it's a good thing to have:)
> > >
> > > John Wilson
> > > The Wilson Partnership
> > > web http://www.wilson.co.uk
> > > blog http://eek.ook.org
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

123