realbasic-nug
[Top] [All Lists]

RE: More date weirdness

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: RE: More date weirdness
From: "Tim Hare" <tim at telios dot com>
Date: Sat, 28 Oct 2006 23:17:42 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Importance: Normal
Also, the line

dim d, theDate as new date

is dangerous.  Depending on the version of RB you're running, you could wind
up with two date pointers pointing to the same object.  In that case, when
you change one, the other would reflect the same change.  It's much safer to
code it as

dim d, theDate as date
d= new date
theDate= new date

Tim


> -----Original Message-----
> From: realbasic-nug-bounces at lists dot realsoftware dot com
> [mailto:realbasic-nug-bounces at lists dot realsoftware dot com]On Behalf Of 
> Fargo
> Holiday
> Sent: Saturday, October 28, 2006 10:46 PM
> To: REALbasic NUG
> Subject: Re: More date weirdness
>
>
> You should examine theDate.totalseconds+i+j+s in your second message
> box, since that's what you're comparing against.You'll find that changes
> your perception.
> Like this: MsgBox "Nope." + Format(d.totalseconds, "##########")+
> EndOfLine +Format((theDate.totalseconds+i+j+s), "##########")
>
> Jeffrey Ellis wrote:
> > So. I have a fairly simply little calculation which is failing.
> >
> > I'm trying to compare a user-entered date and time to the
> current date and
> > time.
> >
> > Here's the code:
> >
> >   Dim d, theDate as new date
> >   dim h, m, s, i, j as integer
> >   dim edate, formatTotalSeconds as string
> >   Dim t as Boolean
> >
> >
> >   edate=EnterDate.text//the EnterDate editfield
> >   h=val(hour.text)//the hour editfield
> >   i=h*60*60
> >   m=val(min.text)//the minute editfield
> >   j=m*60
> >   s=val(sec.text)//the second editfield
> >
> >   t=ParseDate(edate,theDate)
> >
> >   theDate.hour=h
> >   theDate.Minute=m
> >   theDate.second=s
> >
> >   If d.totalseconds>=(theDate.totalseconds+i+j+s) Then
> >     beep
> >     MsgBox Format(d.totalseconds, "#######################")+"
> > "+Format(theDate.totalseconds, "#######################")
> >   else
> >     MsgBox"Nope. Format(d.totalseconds, "##########")+"
> > "+Format(theDate.totalseconds, "##########")
> >   End If
> >
> > My Result at 10:20:40pm on 10/28/06, with the User fields being set to
> > 10/28/06 22 20 00 respectively was:
> >
> > d.totalseconds=3244918841
> > theDate.totalseconds=3244918800
> >
> > Now clearly, 3244918841 is > than 3244918800
> >
> > And yet, I get the second msgBox!
> >
> > Can someone please enlighten me?
> >
> > All My Best,
> > Jeffrey
> >
> >
> > _______________________________________________
> > Unsubscribe or switch delivery mode:
> > <http://www.realsoftware.com/support/listmanager/>
> >
> > Search the archives of this list here:
> > <http://support.realsoftware.com/listarchives/lists.html>
> >
> >
> >
> >
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
>
>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>