[Gambas-user] Strange problem with Date Time and ValueBox
Richard
richard.j.walker at ...247...
Sat Mar 8 00:31:34 CET 2008
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
More information about the User
mailing list