[futurebasic] Re: Adjusting time

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: pochas <pochas@...>
Date: Tue, 24 Aug 1999 03:30:44 -0400
> >From: Ken Shmidheiser <kshmidheiser@...>
> >
 > I'm working on a app where I want the user to be able to see both the
> > current time, and the time adjusted for time zone differences. How do
> > I add or subtract time from the system time to compensate for the
> > time zone differences? I haven't had any success with the manual's
> > suggestion (page 310):
> >

Ken, I worked this one out some time ago.

I found that the toolbox calls SECS2DATE and DATE2SECS work in FB if it
is understood that the seconds of system time are an unsigned integer. 
Work around this by zeroing the hi bit when getting seconds, and
resetting it when converting seconds to the date record.  The following
shows how to convert a date to seconds, add an hour, and convert the
seconds to a date using toolbox calls. Of course, if you want to start
with the system time, just use err% = FN READTIME(secs&)

dateRecord.year% = 1999
dateRecord.month% = 6
dateRecord.day% = 24
dateRecord.hour% = 10
dateRecord.minute% = 40

secs& = FN DATE2SECS (@dateRecord) AND &7FFFFFFF
secs& = (secs& + 3600) OR &80000000

CALL SECS2DATE(secs&,@dateRecord)

WINDOW 1
PRINT "year ";dateRecord.year%
PRINT "month ";dateRecord.month%
PRINT "day ";dateRecord.day%
PRINT "hour ";dateRecord.hour%
PRINT "minute ";dateRecord.minute%

DO
  HANDLEEVENTS
UNTIL 0

Hope this helps.  Charles P.