19 #ifndef __DATETIMEUTILS__
20 #define __DATETIMEUTILS__
22 #ifndef __CONDITIONALMACROS__
43 #if PRAGMA_STRUCT_ALIGN
44 #pragma options align = mac68k
45 #elif PRAGMA_STRUCT_PACKPUSH
47 #elif PRAGMA_STRUCT_PACK
121 dayOfWeekMask = 0x0080,
122 dayOfYearMask = 0x0100,
123 weekOfYearMask = 0x0200,
129 typedef SInt8 LongDateField;
148 typedef SInt8 DateForm;
177 dateTimeNotFound = 0x8400,
178 dateTimeInvalid = 0x8800
181 typedef short StringToDateStatus;
182 typedef StringToDateStatus String2DateStatus;
240 typedef SInt8 DateDelta;
261 DateString(
long dateTime, DateForm longFlag, Str255 result, Handle intlHandle);
420 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
421 #pragma parameter __D0 ReadDateTime(__A0)
443 It is recommended that you obtain the value
using the GetDateTime trap
444 rather than
using the low-memory variable however, as it is possible that
445 low-memory variables may change in the future.
446 You can convert the
secs value to a more understandable value (i.e., a
448 The
ReadDateTime function may
return a slightly more accurate value
449 since it is possible
for the Time variable to lose seconds when interrupts
450 get disabled
for very
long.
451 Since the base
date for the
"raw seconds" value is 1/1/1904 and since
secs
452 is a 32-bit value, you won
't be able to calculate with dates beyond February
455 * \copyright THINK Reference © 1991-1992 Symantec Corporation
456 * \non_carbon_cfm in InterfaceLib 7.1 and later
457 * \carbon_lib in CarbonLib 1.0 and later
458 * \mac_os_x in version 10.0 and later
460 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
461 #pragma parameter GetDateTime(__A0)
464 GetDateTime(unsigned long *secs);
492 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
493 #pragma parameter __D0 SetDateTime(__D0)
496 SetDateTime(unsigned long time);
520 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
521 #pragma parameter SetTime(__A0)
524 SetTime(const DateTimeRec *d);
540 printf("Today is %d/%d/%d\n", now.month, now.day, now.year);
541 printf("The first day of the rest of your life. . . ");
543 * \copyright THINK Reference © 1991 - 1992 Symantec Corporation
544 * \non_carbon_cfm in InterfaceLib 7.1 and
546 * \carbon_lib in CarbonLib 1.0 and
548 * \mac_os_x in version 10.0 and
551 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
552 #pragma parameter GetTime(__A0)
555 GetTime(DateTimeRec *d);
566 DateToSeconds(const DateTimeRec *d, unsigned long *secs);
576 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
577 #pragma parameter SecondsToDate(__D0, __A0)
580 SecondsToDate(unsigned long secs, DateTimeRec *d);
586 #if CALL_NOT_IN_CARBON
596 IUDateString(long dateTime, DateForm longFlag, Str255 result);
628 IUTimeString(nowNum, TRUE, nowStr); /* exclude seconds */
629 DrawString("\pThe time is: ");
632 * \copyright THINK Reference © 1991 - 1992 Symantec Corporation
633 * \non_carbon_cfm in InterfaceLib 7.1 and
635 * \carbon_lib not available * \mac_os_x not available *
638 IUTimeString(long dateTime, Boolean wantSeconds, Str255 result);
649 IUDatePString(long dateTime, DateForm longFlag, Str255 result,
684 Intl0Hndl i0h; /* handle to an Intl0Rec */
685 i0h = (Intl0Hndl)IUGetIntl(0); /* get current settings */
686 (*i0h)->timeCycle = 0; /* 24-hr format */
687 (*i0h)->timeFmt |= secLeadingZ | minLeadingZ | hrLeadingZ;
689 * \copyright THINK Reference © 1991 - 1992 Symantec Corporation
690 * \non_carbon_cfm in InterfaceLib 7.1 and
692 * \carbon_lib not available * \mac_os_x not available *
695 IUTimePString(long dateTime, Boolean wantSeconds, Str255 result,
707 IULDateString(LongDateTime *dateTime, DateForm longFlag, Str255 result,
719 IULTimeString(LongDateTime *dateTime, Boolean wantSeconds, Str255 result,
722 #endif /** CALL_NOT_IN_CARBON */
724 #if CALL_NOT_IN_CARBON
725 #define DateString(dateTime, longFlag, result, intlHandle) \
726 IUDatePString(dateTime, longFlag, result, intlHandle)
727 #define TimeString(dateTime, wantSeconds, result, intlHandle) \
728 IUTimePString(dateTime, wantSeconds, result, intlHandle)
729 #define LongDateString(dateTime, longFlag, result, intlHandle) \
730 IULDateString(dateTime, longFlag, result, intlHandle)
731 #define LongTimeString(dateTime, wantSeconds, result, intlHandle) \
732 IULTimeString(dateTime, wantSeconds, result, intlHandle)
733 #endif /** CALL_NOT_IN_CARBON */
735 #define String2Date(textPtr, textLen, theCache, lengthUsed, dateTime) \
736 StringToDate(textPtr, textLen, theCache, lengthUsed, dateTime)
737 #define String2Time(textPtr, textLen, theCache, lengthUsed, dateTime) \
738 StringToTime(textPtr, textLen, theCache, lengthUsed, dateTime)
739 #define LongDate2Secs(lDate, lSecs) LongDateToSeconds(lDate, lSecs)
740 #define LongSecs2Date(lSecs, lDate) LongSecondsToDate(lSecs, lDate)
741 #define Date2Secs(d, secs) DateToSeconds(d, secs)
742 #define Secs2Date(secs, d) SecondsToDate(secs, d)
743 #endif /** OLDROUTINENAMES */
745 #if CALL_NOT_IN_CARBON
755 iudatestring(long dateTime, DateForm longFlag, char *result);
766 iudatepstring(long dateTime, DateForm longFlag, char *result,
778 iutimestring(long dateTime, Boolean wantSeconds, char *result);
789 iutimepstring(long dateTime, Boolean wantSeconds, char *result,
801 iuldatestring(LongDateTime *dateTime, DateForm longFlag, char *result,
813 iultimestring(LongDateTime *dateTime, Boolean wantSeconds, char *result,
816 #endif /** CALL_NOT_IN_CARBON */
818 #if PRAGMA_STRUCT_ALIGN
819 #pragma options align = reset
820 #elif PRAGMA_STRUCT_PACKPUSH
822 #elif PRAGMA_STRUCT_PACK
826 #ifdef PRAGMA_IMPORT_OFF
836 #endif /** __DATETIMEUTILS__ */
837 * /*/*/ * /*/*/ * /*/*/
Set up for compiler independent conditionals.
SInt16 ToggleResults
Definition: DateTimeUtils.h:81
@ cantReadUtilities
Definition: DateTimeUtils.h:176
@ fatalDateTime
Definition: DateTimeUtils.h:159
@ leftOverChars
Definition: DateTimeUtils.h:162
@ extraneousStrings
Definition: DateTimeUtils.h:168
@ sepNotIntlSep
Definition: DateTimeUtils.h:164
@ tokenErr
Definition: DateTimeUtils.h:174
@ fieldOrderNotIntl
Definition: DateTimeUtils.h:166
@ sepNotConsistent
Definition: DateTimeUtils.h:172
@ tooManySeps
Definition: DateTimeUtils.h:170
@ longDateFound
Definition: DateTimeUtils.h:161
void LongSecondsToDate(const LongDateTime *lSecs, LongDateRec *lDate)
secs
Obtain "raw seconds" value of Time variable.
Definition: DateTimeUtils.h:442
@ toggleErr3
Definition: DateTimeUtils.h:93
@ toggleUndefined
Definition: DateTimeUtils.h:85
short ValidDate(const LongDateRec *vDate, long flags, LongDateTime *newSecs)
Check the validity of a long date record.
OSErr InitDateCache(DateCachePtr theCache)
StringToDateStatus StringToDate(Ptr textPtr, long textLen, DateCachePtr theCache, long *lengthUsed, LongDateRec *dateTime)
void LongDateToSeconds(const LongDateRec *lDate, LongDateTime *lSecs)
void LongTimeString(const LongDateTime *dateTime, Boolean wantSeconds, Str255 result, Handle intlHandle)
void TimeString(long dateTime, Boolean wantSeconds, Str255 result, Handle intlHandle)
StringToDateStatus StringToTime(Ptr textPtr, long textLen, DateCachePtr theCache, long *lengthUsed, LongDateRec *dateTime)
void LongDateString(const LongDateTime *dateTime, DateForm longFlag, Str255 result, Handle intlHandle)
ToggleResults ToggleDate(LongDateTime *lSecs, LongDateField field, DateDelta delta, short ch, const TogglePB *params)
Modify a LongDateTime parameter.
#define DateString(dateTime, longFlag, result, intlHandle)
Definition: DateTimeUtils.h:725
@ smallDateBit
Definition: DateTimeUtils.h:101
@ togCharZCycleBit
Definition: DateTimeUtils.h:103
@ togChar12HourBit
Definition: DateTimeUtils.h:102
@ genCdevRangeBit
Definition: DateTimeUtils.h:107
@ validDateFields
Definition: DateTimeUtils.h:108
@ togDelta12HourBit
Definition: DateTimeUtils.h:105
OSErr ReadDateTime(unsigned long *time)
Copy clock-chip time to Time variable.
Basic Macintosh data types.
unsigned char Boolean
Definition: MacTypes.h:318
@ date
Definition: ROMDefs.h:267
Definition: DateTimeUtils.h:184
Definition: DateTimeUtils.h:190
Definition: DateTimeUtils.h:242
ResType amChars
Definition: DateTimeUtils.h:244
ResType pmChars
Definition: DateTimeUtils.h:245
Definition: MacTypes.h:104
Definition: DateTimeUtils.h:203
Definition: DateTimeUtils.h:221