Schedule+ has a special way of dealing with dates and times. Items can have Date, Time, and Date/Time properties. Date/Time properties contain both the date and time components, and map directly to the Visual Basic Date data type. Date, Time, and Date/Time properties must be converted to a special 32-bit format before they can be used by Schedule+, then converted back before being assigned to the Visual Basic Date data type.
The following sample code uses the Visual Basic DateConvertFromLong function to convert the Long parameter to a Visual Basic Date:
Function DateConvertFromLong(ByVal DateSrc As Long) As Date
‘Use integer division to avoid rounding up.
DateConvertFromLong = DateSerial((DateSrc \ 512),
((DateSrc \ 32) Mod 16), (DateSrc Mod 32))
End Function
The following sample code uses the Visual Basic TimeConvertFromLong function to convert the Long parameter to a Visual Basic Time:
Function TimeConvertFromLong(ByVal TimeSrc As Long) As Date
‘Use integer division to avoid rounding up.
TimeConvertFromLong = TimeSerial((TimeSrc \ 4096),
(TimeSrc \ 64) Mod 64, (TimeSrc Mod 64))
End Function
The following sample code uses the Visual Basic LConvertTo32bitDate function to convert the Date parameter to a 32-bit date, which can be used as the date in Automation:
Function LConvertTo32bitDate(ByVal DateSrc As Date) As Long
LConvertTo32bitDate = (Year(DateSrc) * 512) +
(Month(DateSrc) * 32) + (Day(DateSrc))
End Function
The following sample code uses the Visual Basic LConvertTo32bitTime function to convert the Date parameter to a 32-bit time, which can be used as the time in Automation:
Function LConvertTo32bitTime(ByVal DateSrc As Date) As Long
LConvertTo32bitTime = (Hour(DateSrc) * 4096) +
(Minute(DateSrc) * 64) + Second(DateSrc)
End Function