[Gambas-user] Strange problem with Date Time and ValueBox

Richard richard.j.walker at ...247...
Tue Mar 11 22:55:51 CET 2008


On Tuesday 11 March 2008 12:42:44 Benoit Minisini wrote:
> On samedi 8 mars 2008, Richard wrote:
> > I have a little program which I wrote for the last winter Ashes tour. It
> > provides a way to do timer controlled recordings from radio programmes
> > streamed by the BBC and played by Helixplayer.
> >
> > I have tinkered with it from time to time to bloat its feature set and
> > keep it up to date with various key changes to the Gambas2 environment.
> > The current working version is in use recording each day's play in the 3
> > test series under way in New Zealand. It runs on Gambas2 v2.0 with a
> > backported bug-fix for the date chooser control which Benoit kindly
> > provided.
> >
> > I have always found plenty to confuse me when handling dates and times in
> > Gambas but having converted from my own customised versions of the
> > DateBox and TimeBox controls to the new ValueBox control I had reviewed
> > the date and time handling code to make sure I am not doing any redundant
> > conversions.
> >
> > Something I changed recently introduced a bug to the
> > store-recall-timer-settings process. A date and time entered as
> > {02/03/2008 15:45:11} is changed, when it is recalled from a storage
> > array, to {02/03/2008 00:41:26}.
> >
> > A lot of time spent tracing through my over-complex logic eventually
> > located the probable "cause" in part of the code which restores a
> > previously stored collection of settings.  The relevant code snippet is:
> >
> >         'Timer tab controls
> >         LineRecord.StartDateChooser.Value = Date(records[ix].Start_Time)
> >         LineRecord.StartDateBox.Value = Date(records[ix].Start_Time)
> >         'Do not trigger selected Change events
> >         LineRecord.INC_autoset
> >         LineRecord.HourTimeSet.Value = Hour(records[ix].Start_Time)
> >         LineRecord.MinuteTimeset.Value = Minute(records[ix].Start_Time)
> >         LineRecord.SecondTimeSet.Value = Second(records[ix].Start_Time)
> >         'Re-enable selected Change events
> >         LineRecord.DEC_autoset
> >         'LineRecord.StartTimeBox.Value = Time(records[ix].Start_Time)
> >         LineRecord.StartTimeBox.Value = (records[ix].Start_Time)
> >
> > In the last two lines the version commented out is the line which
> > introduces the incorrect time. The line below works just fine. The
> > records array is an array of objects of Class Recording. The
> > Recording.Start_Time property is a Date value with both date and time
> > parts.
> >
> > Until this week the first two lines, and the penultimate, simply assigned
> > the whole date/time value to the DateChooser, StartDateBox  and the
> > StartTimeBox. I decided to make it more "correct" after reading about the
> > Date and Time conversion functions. Only the Time(date_variable) line is
> > "wrong". Reverting to the old sloppy way fixes the problem.
> >
> > Here's the question: Has anyone come across a similar problem in
> > date/time handling? I have tried replicating the problem in independent
> > code with no success.
> >
> >
> > Richard
>
> Can you provide the full source code? 
Yes, can do, but it isn't pretty. The source archive is currently 640k, but 
that includes a lot of clutter in the project img folder.
> And can you use DEBUG or PRINT 
> instruction to the prints the value of records[ix].Start_Time before
> assigning it?
I found the rogue value while stepping through the code using the debugger and 
the Watch pane. 
>
> Regards,

I have also tried to replicate the problem in stand-alone code (a test 
project) which simply does the same logical things with date and time values, 
but that worked perfectly; just the way you would expect. My guess at this 
stage is that I have managed to create an inconsistency somewhere. The 
observation that nobody else has come across the same snag would seem to 
confirm that the bug is mine all mine!

I'll do some more searching now that the latest modifications to the 
application are working and I'll get back to you if I need more help.

Richard






More information about the User mailing list