[futurebasic] Re: ERROR BETWEEN OSX AND OS9

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2005 : Group Archive : Group : All Groups

From: David Bailey <dabs@...>
Date: Mon, 17 Jan 2005 15:24:15 -0800
OK can anybody tell me why compiling and running this in OSX vs. OS9  
returns a difference of days between the dates passed??  There is one  
day difference and I'll be darned if I can see why.....


David

-----------------------------------------
#define CFAbsoluteTime as double
#define CFTimeZoneRef  as Ptr

begin record CFGregorianDate
dim as SInt32  year
dim as SInt8   month, day, hour, minute
begin union
dim as double  second
dim as SInt64  splitSec// for passing as 2 longs in FB
end union
end record

begin record CFGregorianUnits
dim as SInt32  years, months, days, hours, minutes
begin union
dim as double  seconds
dim as SInt64  splitSecs// for passing as 2 longs in FB
end union
end record

'CFGregorianUnitFlags
_kCFGregorianUnitsYears   = 1 << 0
_kCFGregorianUnitsMonths  = 1 << 1
_kCFGregorianUnitsDays    = 1 << 2
_kCFGregorianUnitsHours   = 1 << 3
_kCFGregorianUnitsMinutes = 1 << 4
_kCFGregorianUnitsSeconds = 1 << 5
_kCFGregorianAllUnits     = 0x00FFFFFF

toolbox fn CFGregorianDateIsValid( long year,long  
monthDayHourMinute,long hiSecs,long loSecs,CFOptionFlags unitFlags ) =  
Boolean
toolbox fn CFGregorianDateGetAbsoluteTime( long year,long  
monthDayHourMinute,long hiSec,long loSec,CFTimeZoneRef tz ) =  
CFAbsoluteTime
toolbox CFAbsoluteTimeGetDifferenceAsGregorianUnits( CFGregorianUnits  
*result,CFAbsoluteTime at1,CFAbsoluteTime at2,CFTimeZoneRef  
tz,CFOptionFlags unitFlags )

'Glue functions to simplify the calls...
local fn CFGregorianDateIsValid_Glue(d as ^CFGregorianDate,unitFlags as  
CFOptionFlags)
end fn = fn CFGregorianDateIsValid(d.year,(d.month<<24) + (d.day<<16) +  
(d.hour<<8)+d.minute, d.splitSec.hi,d.splitSec.lo,unitFlags)
'~';
local fn CFGregorianDateGetAbsoluteTime_Glue#(d as ^CFGregorianDate,tz  
as CFTimeZoneRef)
end fn = fn CFGregorianDateGetAbsoluteTime(d.year,(d.month<<24) +  
(d.day<<16)+(d.hour<<8) + d.minute, d.splitSec.hi, d.splitSec.lo,tz)


clear local
dim as CFGregorianDate   d
dim as CFAbsoluteTime    was, now
dim as CFGregorianUnits  diff
'~'2
local fn DayDifference(year as SInt32,month as SInt8,day as SInt8,year2  
as SInt32,month2 as SInt8,day2 as SInt8)
'~'2
d.year = year2
d.month = month2
d.day = day2
d.hour   = 0
d.minute = 0
d.second = 0.0
now = fn CFGregorianDateGetAbsoluteTime_Glue#(d,0)
d.year   = year
d.month  = month
d.day    = day
d.hour   = 0
d.minute = 0
d.second = 0.0
long if (fn CFGregorianDateIsValid_Glue(d,_kCFGregorianAllUnits))
was = fn CFGregorianDateGetAbsoluteTime_Glue#(d,0)
CFAbsoluteTimeGetDifferenceAsGregorianUnits(@diff,now,was,0,_kCFGregoria 
nUnitsDays)
xelse
print "Bad date supplied"
end if
end fn = diff.days



window 1

Text 0,24,0,0
PRINT%(100,100)fn DayDifference(1900,1,1,2005,1,1)

DO
HANDLEEVENTS
UNTIL 0