aUCBLogo Demos and Tests / cheetah_dateroutines
to cheetah_dateroutines ; DATE ROUTINES THAT WORK WITH CHEETAH DATES
::xdb = DynamicLibrary "cheetah2.dll
end
to dr_xdbDaysApart DateFrom DateTo
comment [The functions below are designed to help the Cheetah programmer with manipulating dates. Dates in Cheetah are stored in traditional xBase format as YYYYMMDD. This corresponds to a Type "D" field. Dealing with dates in character format can be a little cumbersome. These routines should make them easier to deal with.]
comment [DECLARE FUNCTION xdbDaysApart&(DateFrom$, DateTo$) Determine how may days separate the two dates. The dates must enter in the YYYYMMDD format.]
output DLCall xdb [XDBDAYSAPART_Z] (list "Int
"DateFrom "Word DateFrom
"DateTo "Word DateTo )
end
to dr_xdbDaysInMonth Year Month
comment [ DECLARE FUNCTION xdbDaysInMonth&(BYVAL Year&, BYVAL Month&) Simply determines how many days are in a given month. This function is leap-year aware, therefore the need to specify the year. The year must be in 4-digit format (e.g. 1995, not 95).]
output DLCall xdb [XDBDAYSINMONTH_Z] (list "Int
"Year "Int Year
"Month "Int Month )
end
to dr_xdbAddDate StartDate Days
comment [ DECLARE FUNCTION xdbAddDate$(StartDate$, BYVAL Days&) This function returns a date (in format YYYYMMDD) that is the addition of the date specified and the number of days. If the number of days specified is negative, then the date returnedis the number of days before the date specified.]
output DLCall xdb [XDBADDDATE_Z] (list "Word
"StartDate "Word StartDate
"Days "Int Days )
end
to dr_xdbNameOfDay DateCheck
comment [ DECLARE FUNCTION xdbNameOfDay$(DateCheck$) Given a date in YYYYMMDD format, this function returns the day of the week.]
output DLCall xdb [XDBNAMEOFDAY_Z] (list "Word
"DateCheck "Word DateCheck )
end
to dr_xdbTodaysDate
comment [ DECLARE FUNCTION xdbTodaysDate$ This function returns a date (in YYYYMMDD format) based on the computer's current system date.]
output DLCall xdb [XDBTODAYSDATE_Z] (list "Word )
end
to dr_xdbValidDate DateCheck
comment [ DECLARE FUNCTION xdbValidDate&(DateCheck$) This function returns either %XDBTRUE or %XDBFALSE depending whether the date passed to it (in YYYYMMDD format) is valid or not. Note: Do not test this function using the NOT operator! You must test it directly (e.g. IF xdbValidDate&("19951231") = %XDBTRUE THEN)]
output DLCall xdb [XDBVALIDDATE_Z] (list "Int
"DateCheck "Word DateCheck )
end
to dr_xdbDateToJulian DateString
comment [ DECLARE FUNCTION xdbDateToJulian&(DateString$) This function converts a date (in YYYYMMDD format) to a long integer. The value is referredto as a Julian date and is very useful when performing date arithmetic. The long integers canbe added or subtracted to determine other dates.]
output DLCall xdb [XDBDATETOJULIAN_Z] (list "Int
"DateString "Word DateString )
end
to dr_xdbJulianToDate JulianNumber
comment [ DECLARE FUNCTION xdbJulianToDate$(BYVAL JulianNumber&) This function simply converts a long integer in Julian format to a date string in YYYYMMDD format.]
output DLCall xdb [XDBJULIANTODATE_Z] (list "Word
"JulianNumber "Int JulianNumber )
end
to dr_xdbCTOD PBDate
comment [ FUNCTION CTOD(PBDate AS STRING)This function takes a standard BASIC date format (MM-DD-YYYY) and converts it into a Cheetah(xBase) date (YYYYMMDD).]
output DLCall xdb [CTOD_Z] (list "Word
"PBDate "Word PBDate )
end
to dr_xdbDTOS xDate
comment [ FUNCTION DTOS(xDate AS STRING) This function takes a Cheetah (xBase) date (YYYYMMDD) and converts it into a standard BASICformat date (MM-DD-YYYY).]
output DLCall xdb [DTOS_Z] (list "Word
"xDate "Word xDate )
end
to dr_xdbVersion
comment [ This routine returns a string representing the version of the Cheetah DLL and other information. You can use this information when requesting technical support.]
output DLCall xdb [XDBVERSION_Z] (list "Word )
end
;bury [cheetah_dateroutines dr_xdbDaysApart dr_xdbDaysInMonth dr_xdbAddDate dr_xdbNameOfDay dr_xdbTodaysDate dr_xdbValidDate dr_xdbDateToJulian dr_xdbJulianToDate dr_xdbCTOD dr_xdbDTOS dr_xdbVersion]