home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TimeObjects.h
-
- Contains: International Time Interfaces.
-
- Version: Technology: System 8
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __TIMEOBJECTS__
- #define __TIMEOBJECTS__
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
- #ifndef __KERNEL__
- #include <Kernel.h>
- #endif
- #ifndef __LOCALEOBJECTS__
- #include <LocaleObjects.h>
- #endif
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
- #ifndef __TEXTOBJECTS__
- #include <TextObjects.h>
- #endif
- #ifndef __TIMING__
- #include <Timing.h>
- #endif
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /*
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ++ ++
- ++ Type definitions for Modern APIs ++
- ++ ++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
- #if FOR_SYSTEM8_PREEMPTIVE
- /* Precision of TimeObject */
- typedef UInt8 TimeObjectPrecision;
-
- enum {
- kTONanosecondsPrecision = 0x00,
- kTOMicrosecondsPrecision = 0x01,
- kTOMillisecondsPrecision = 0x02,
- kTOSecondsPrecision = 0x03,
- kTOMinutesPrecision = 0x04,
- kTOHoursPrecision = 0x05,
- kTODaysPrecision = 0x06
- };
-
- /* Maximun Time Object Precision */
-
- enum {
- kTOMaxPrecision = kTODaysPrecision
- };
-
- typedef UInt32 TimeObjectNotificationRef;
- struct MachineLocationRecord {
- Fixed longitude;
- Fixed latitude;
- TimeObjectInterval daylightSavingsDelta;
- TimeObjectInterval utcDelta;
- };
- typedef struct MachineLocationRecord MachineLocationRecord;
-
- typedef MachineLocationRecord *MachineLocationRecordPtr;
- typedef const MachineLocationRecord *ConstMachineLocationRecordPtr;
- struct UTCTimeRecord {
- UInt16 era; /* [0 = B.C.E., 1 = C.E. ]*/
- UInt16 year; /* [0, 65535]*/
- UInt16 month; /* [0,12]*/
- UInt16 day; /* [0,32]*/
- UInt16 hour; /* [0,23]*/
- UInt16 minute; /* [0,60]*/
- UInt16 seconds; /* [0,60]*/
- UInt16 milliseconds; /* [0,1e3)*/
- UInt32 microseconds; /* [0,1e6)*/
- UInt32 nanoseconds; /* [0,1e9)*/
- TimeObjectPrecision precision;
- };
- typedef struct UTCTimeRecord UTCTimeRecord;
-
- typedef UTCTimeRecord *UTCTimeRecordPtr;
- typedef const UTCTimeRecord *ConstUTCTimeRecordPtr;
- struct UTCTimeIntervalRecord {
- SInt32 day;
- SInt32 hour;
- SInt32 minute;
- SInt32 seconds;
- SInt32 milliseconds;
- SInt32 microseconds;
- SInt32 nanoseconds;
- TimeObjectPrecision precision;
- };
- typedef struct UTCTimeIntervalRecord UTCTimeIntervalRecord;
-
- typedef UTCTimeIntervalRecord *UTCTimeIntervalRecordPtr;
- typedef const UTCTimeIntervalRecord *ConstUTCTimeIntervalRecordPtr;
- typedef UInt32 TimeObjectConversionType;
-
- enum {
- kUseRomanNumbers = 0L,
- kUseNativeNumbers = 1L
- };
-
- typedef LocaleObjectRef CalendarObjectRef;
- typedef TextObject TimeObjectFormatString;
- /* DateTimeFormat Types: */
- typedef UInt32 FormatStringRef;
-
- enum {
- kPreferredDateTimeFormat = 0L,
- kShortDateTimeFormat = 1L,
- kLongDateTimeFormat = 2L,
- kShortTimeFormat = 3L,
- kLongTimeFormat = 4L
- };
-
- #endif
- /*
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ++ ++
- ++ Type definitions for Legacy APIs ++
- ++ ++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- /*
-
- Here are the current routine names and the translations to the older forms.
- Please use the newer forms in all new code and migrate the older names out of existing
- code as maintainance permits.
-
- New Name Old Name(s)
-
- DateString IUDatePString IUDateString
- InitDateCache
- LongDateString IULDateString
- LongTimeString IULTimeString
- StringToDate String2Date
- StringToTime
- TimeString IUTimeString IUTimePString
- */
-
- enum {
- shortDate = 0,
- longDate = 1,
- abbrevDate = 2
- };
-
- typedef SInt8 DateForm;
-
- enum {
- /* StringToDate status values */
- fatalDateTime = 0x8000, /* StringToDate and String2Time mask to a fatal error */
- longDateFound = 1, /* StringToDate mask to long date found */
- leftOverChars = 2, /* StringToDate & Time mask to warn of left over characters */
- sepNotIntlSep = 4, /* StringToDate & Time mask to warn of non-standard separators */
- fieldOrderNotIntl = 8, /* StringToDate & Time mask to warn of non-standard field order */
- extraneousStrings = 16, /* StringToDate & Time mask to warn of unparsable strings in text */
- tooManySeps = 32, /* StringToDate & Time mask to warn of too many separators */
- sepNotConsistent = 64, /* StringToDate & Time mask to warn of inconsistent separators */
- tokenErr = 0x8100, /* StringToDate & Time mask for 'tokenizer err encountered' */
- cantReadUtilities = 0x8200,
- dateTimeNotFound = 0x8400,
- dateTimeInvalid = 0x8800
- };
-
- typedef short StringToDateStatus;
- typedef short String2DateStatus;
- struct DateCacheRecord {
- short hidden[256]; /* only for temporary use */
- };
- typedef struct DateCacheRecord DateCacheRecord;
-
- typedef DateCacheRecord *DateCachePtr;
- #endif
- /*
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ++ ++
- ++ Modern API Definitions ++
- ++ ++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
- #if FOR_SYSTEM8_PREEMPTIVE
- /*
- *********************************************************
- *
- * TimeObject Constructors
- *
- *********************************************************
- */
- extern OSStatus CreateTimeObject(TimeObjectPtr timeObject, ConstUTCTimeRecordPtr utcTime);
-
- extern OSStatus CreateTimeObjectInterval(TimeObjectIntervalPtr timeObjectInterval, ConstUTCTimeIntervalRecordPtr utcTimeInterval);
-
- /*
- *********************************************************
- *
- * Getter and Setter Functions for TimeObjects
- *
- *********************************************************
- */
- extern OSStatus GetCurrentTime(TimeObjectPtr timeObj);
-
- extern OSStatus SetCurrentTime(ConstTimeObjectPtr timeObj);
-
- /*
- *********************************************************
- *
- * Getter and Setter Functions for Machine Location
- *
- *********************************************************
- */
- extern OSStatus GetMachineLocation(MachineLocationRecordPtr machineLocation);
-
- extern OSStatus SetMachineLocation(ConstMachineLocationRecordPtr machineLocation);
-
- /*
- *********************************************************
- *
- * Getter and Setter Functions for TimeObjects Precision
- *
- *********************************************************
- */
- extern OSStatus GetTimeObjectPrecision(ConstTimeObjectPtr timeObj, TimeObjectPrecision *precision);
-
- extern OSStatus SetTimeObjectPrecision(TimeObjectPtr timeObj, TimeObjectPrecision precision);
-
- extern OSStatus GetTimeObjectIntervalPrecision(ConstTimeObjectIntervalPtr timeObj, TimeObjectPrecision *precision);
-
- extern OSStatus SetTimeObjectIntervalPrecision(TimeObjectIntervalPtr timeObj, TimeObjectPrecision precision);
-
- /*
- *********************************************************
- *
- * Timers
- *
- *********************************************************
- */
- extern OSStatus CreateTimeObjectNotifier(ConstTimeObjectPtr timeObject, KernelNotification *notifier, TimeObjectNotificationRef *notificationRef);
-
- extern OSStatus CancelTimeObjectNotifier(TimeObjectNotificationRef notificationRef);
-
- /*
- *********************************************************
- *
- * Manipulation and Comparison functions for TimeObjects
- *
- *********************************************************
- */
- extern OSStatus AddToFixedTimeObject(ConstTimeObjectPtr fixedTimeObj, ConstTimeObjectIntervalPtr offsetTimeObj, TimeObjectPtr result);
-
- extern OSStatus AddTimeObjectIntervals(ConstTimeObjectIntervalPtr timeObj1, ConstTimeObjectIntervalPtr timeObj2, TimeObjectIntervalPtr result);
-
- extern OSStatus SubtractFromFixedTimeObject(ConstTimeObjectPtr fixedTimeObj, ConstTimeObjectIntervalPtr offsetTimeObj, TimeObjectPtr result);
-
- extern OSStatus SubtractTimeObjectIntervals(ConstTimeObjectIntervalPtr timeObj1, ConstTimeObjectIntervalPtr timeObj2, TimeObjectIntervalPtr result);
-
- extern OSStatus SubtractFixedTimeObjects(ConstTimeObjectPtr timeObj1, ConstTimeObjectPtr timeObj2, TimeObjectIntervalPtr result);
-
- extern OSStatus CompareFixedTimeObjects(ConstTimeObjectPtr timeObj1, ConstTimeObjectPtr timeObj2, ConstTimeObjectIntervalPtr precision, SInt32 *result);
-
- extern OSStatus CompareTimeObjectIntervals(ConstTimeObjectIntervalPtr timeObj1, ConstTimeObjectIntervalPtr timeObj2, ConstTimeObjectIntervalPtr precision, SInt32 *result);
-
- /*
- *********************************************************
- *
- * TimeObjects to Seconds from 1/1/04 conversion functions
- *
- *********************************************************
- */
- extern OSStatus ConvertSecondsToTimeObject(UInt32 seconds, TimeObjectPtr convertedTimeObj);
-
- extern OSStatus ConvertTimeObjectToSeconds(ConstTimeObjectPtr timeObj, UInt32 *seconds);
-
- extern OSStatus ConvertLongDateTimeToTimeObject(LongDateTime *longDateTime, TimeObjectPtr convertedTimeObj);
-
- extern OSStatus ConvertTimeObjectToLongDateTime(ConstTimeObjectPtr timeObj, LongDateTime *longDateTime);
-
- /*
- *********************************************************
- *
- * TimeObjectIntervals to Nanosecond conversion functions
- *
- *********************************************************
- */
- extern OSStatus ConvertTimeObjectIntervalToNanoseconds(ConstTimeObjectIntervalPtr source, Nanoseconds *result);
-
- extern OSStatus ConvertNanosecondsToTimeObjectInterval(Nanoseconds *source, TimeObjectIntervalPtr result);
-
- /*
- *********************************************************
- *
- * Internet Time/Mail Conversion Routines
- *
- *********************************************************
- */
- extern OSStatus ConvertTimeObjectToInternetMailTime(ConstTimeObjectPtr source, TextObject result);
-
- extern OSStatus ConvertInternetMailTimeToTimeObject(TextObject source, TimeObjectPtr result);
-
- extern OSStatus ConvertTimeObjectToInternetTime(ConstTimeObjectPtr source, UInt32 *result);
-
- extern OSStatus ConvertInternetTimeToTimeObject(UInt32 internetTime, TimeObjectPtr result);
-
- /*
- *********************************************************
- *
- * Calendar Routines
- *
- *********************************************************
- */
- extern OSStatus GetDefaultCalendar(LocaleRef theLocale, CalendarObjectRef *theCalendar);
-
- extern OSStatus GetDefaultSystemCalendar(CalendarObjectRef *theCalendar);
-
- /*
- *********************************************************
- *
- * Text Conversion Routines
- *
- *********************************************************
- */
- extern OSStatus ConvertTimeObjectToDateString(ConstTimeObjectPtr timeObj, CalendarObjectRef theCalendar, TextObject textObj, TimeObjectFormatString format, FormatStringRef formatSelector, TimeObjectConversionType conversionSelector);
-
- extern OSStatus ConvertTimeObjectToTimeString(ConstTimeObjectIntervalPtr timeObjectInterval, CalendarObjectRef theCalendar, TextObject textObj, TimeObjectFormatString format, FormatStringRef formatSelector, TimeObjectConversionType conversionSelector);
-
- extern OSStatus ConvertDateStringToTimeObject(TimeObjectPtr timeObj, CalendarObjectRef theCalendar, TextObject textObj, TimeObjectConversionType conversionSelector);
-
- extern OSStatus ConvertTimeStringToTimeObject(TimeObjectIntervalPtr timeObjectInterval, CalendarObjectRef theCalendar, TextObject textObj, TimeObjectConversionType conversionSelector);
-
- #endif
- /*
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ++ ++
- ++ Legacy API Definitions ++
- ++ ++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- /*
- **************************************************************************************
- *
- * The following functions are new names that work on 68k and PowerPC
- *
- **************************************************************************************
- */
- extern pascal OSErr InitDateCache(DateCachePtr theCache)
- FOURWORDINLINE(0x2F3C, 0x8204, 0xFFF8, 0xA8B5);
-
- extern pascal StringToDateStatus StringToDate(Ptr textPtr, long textLen, DateCachePtr theCache, long *lengthUsed, LongDateRec *dateTime)
- FOURWORDINLINE(0x2F3C, 0x8214, 0xFFF6, 0xA8B5);
-
- extern pascal StringToDateStatus StringToTime(Ptr textPtr, long textLen, DateCachePtr theCache, long *lengthUsed, LongDateRec *dateTime)
- FOURWORDINLINE(0x2F3C, 0x8214, 0xFFF4, 0xA8B5);
-
- extern pascal void IUDateString(long dateTime, DateForm longFlag, Str255 result)
- TWOWORDINLINE(0x4267, 0xA9ED);
-
- extern pascal void IUTimeString(long dateTime, Boolean wantSeconds, Str255 result)
- THREEWORDINLINE(0x3F3C, 0x0002, 0xA9ED);
-
- extern pascal void IUDatePString(long dateTime, DateForm longFlag, Str255 result, Handle intlHandle)
- THREEWORDINLINE(0x3F3C, 0x000E, 0xA9ED);
-
- extern pascal void IUTimePString(long dateTime, Boolean wantSeconds, Str255 result, Handle intlHandle)
- THREEWORDINLINE(0x3F3C, 0x0010, 0xA9ED);
-
- extern pascal void IULDateString(LongDateTime *dateTime, DateForm longFlag, Str255 result, Handle intlHandle)
- THREEWORDINLINE(0x3F3C, 0x0014, 0xA9ED);
-
- extern pascal void IULTimeString(LongDateTime *dateTime, Boolean wantSeconds, Str255 result, Handle intlHandle)
- THREEWORDINLINE(0x3F3C, 0x0016, 0xA9ED);
-
- /*
- **************************************************************************************
- *
- * The following are macros which map new names to the names exported by InterfaceLib
- *
- **************************************************************************************
- */
- #define DateString(dateTime, longFlag, result, intlHandle) \
- IUDatePString( dateTime, longFlag, result, intlHandle)
- #define TimeString(dateTime, wantSeconds, result, intlHandle) \
- IUTimePString(dateTime, wantSeconds, result, intlHandle)
- #define LongDateString(dateTime, longFlag, result, intlHandle) \
- IULDateString(dateTime, longFlag, result, intlHandle)
- #define LongTimeString(dateTime, wantSeconds, result, intlHandle) \
- IULTimeString(dateTime, wantSeconds, result, intlHandle)
- /*
- **************************************************************************************
- *
- * The following are macros which map old names to the names exported by InterfaceLib
- *
- **************************************************************************************
- */
- #if CGLUESUPPORTED
- #if OLDROUTINENAMES
- extern void iudatestring(long dateTime, DateForm longFlag, char *result);
-
- extern void iudatepstring(long dateTime, DateForm longFlag, char *result, Handle intlHandle);
-
- extern void iutimestring(long dateTime, Boolean wantSeconds, char *result);
-
- extern void iutimepstring(long dateTime, Boolean wantSeconds, char *result, Handle intlHandle);
-
- extern void iuldatestring(LongDateTime *dateTime, DateForm longFlag, char *result, Handle intlHandle);
-
- extern void iultimestring(LongDateTime *dateTime, Boolean wantSeconds, char *result, Handle intlHandle);
-
- #define String2Date(textPtr, textLen, theCache, lengthUsed, dateTime) \
- StringToDate(textPtr, textLen, theCache, lengthUsed, dateTime)
- #define String2Time(textPtr, textLen, theCache, lengthUsed, dateTime) \
- StringToTime(textPtr, textLen, theCache, lengthUsed, dateTime)
- #else
- #endif
- #endif
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __TIMEOBJECTS__ */
-
-