Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

972 lines
27 KiB

  1. /*
  2. File: DateTimeUtils.h
  3. Contains: International Date and Time Interfaces (previously in TextUtils)
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1994-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __DATETIMEUTILS__
  11. #define __DATETIMEUTILS__
  12. #ifndef __CONDITIONALMACROS__
  13. #include <ConditionalMacros.h>
  14. #endif
  15. #ifndef __MACTYPES__
  16. #include <MacTypes.h>
  17. #endif
  18. #ifndef __UTCUTILS__
  19. #include <UTCUtils.h>
  20. #endif
  21. #ifndef __CFDATE__
  22. #include <CFDate.h>
  23. #endif
  24. #if PRAGMA_ONCE
  25. #pragma once
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #if PRAGMA_IMPORT
  31. #pragma import on
  32. #endif
  33. #if PRAGMA_STRUCT_ALIGN
  34. #pragma options align=mac68k
  35. #elif PRAGMA_STRUCT_PACKPUSH
  36. #pragma pack(push, 2)
  37. #elif PRAGMA_STRUCT_PACK
  38. #pragma pack(2)
  39. #endif
  40. /*
  41. Here are the current routine names and the translations to the older forms.
  42. Please use the newer forms in all new code and migrate the older names out of existing
  43. code as maintainance permits.
  44. New Name Old Name(s)
  45. DateString IUDatePString IUDateString
  46. InitDateCache
  47. LongDateString IULDateString
  48. LongTimeString IULTimeString
  49. StringToDate String2Date
  50. StringToTime
  51. TimeString IUTimeString IUTimePString
  52. LongDateToSeconds LongDate2Secs
  53. LongSecondsToDate LongSecs2Date
  54. DateToSeconds Date2Secs
  55. SecondsToDate Secs2Date
  56. Carbon only supports the new names. The old names are undefined for Carbon targets.
  57. This is true for C, Assembly and Pascal.
  58. InterfaceLib always has exported the old names. For C macros have been defined to allow
  59. the use of the new names. For Pascal and Assembly using the new names will result
  60. in link errors.
  61. */
  62. typedef SInt16 ToggleResults;
  63. enum {
  64. /* Toggle results */
  65. toggleUndefined = 0,
  66. toggleOK = 1,
  67. toggleBadField = 2,
  68. toggleBadDelta = 3,
  69. toggleBadChar = 4,
  70. toggleUnknown = 5,
  71. toggleBadNum = 6,
  72. toggleOutOfRange = 7, /*synonym for toggleErr3*/
  73. toggleErr3 = 7,
  74. toggleErr4 = 8,
  75. toggleErr5 = 9
  76. };
  77. enum {
  78. /* Date equates */
  79. smallDateBit = 31, /*Restrict valid date/time to range of Time global*/
  80. togChar12HourBit = 30, /*If toggling hour by char, accept hours 1..12 only*/
  81. togCharZCycleBit = 29, /*Modifier for togChar12HourBit: accept hours 0..11 only*/
  82. togDelta12HourBit = 28, /*If toggling hour up/down, restrict to 12-hour range (am/pm)*/
  83. genCdevRangeBit = 27, /*Restrict date/time to range used by genl CDEV*/
  84. validDateFields = -1,
  85. maxDateField = 10
  86. };
  87. enum {
  88. eraMask = 0x0001,
  89. yearMask = 0x0002,
  90. monthMask = 0x0004,
  91. dayMask = 0x0008,
  92. hourMask = 0x0010,
  93. minuteMask = 0x0020,
  94. secondMask = 0x0040,
  95. dayOfWeekMask = 0x0080,
  96. dayOfYearMask = 0x0100,
  97. weekOfYearMask = 0x0200,
  98. pmMask = 0x0400,
  99. dateStdMask = 0x007F /*default for ValidDate flags and ToggleDate TogglePB.togFlags*/
  100. };
  101. typedef SInt8 LongDateField;
  102. enum {
  103. eraField = 0,
  104. yearField = 1,
  105. monthField = 2,
  106. dayField = 3,
  107. hourField = 4,
  108. minuteField = 5,
  109. secondField = 6,
  110. dayOfWeekField = 7,
  111. dayOfYearField = 8,
  112. weekOfYearField = 9,
  113. pmField = 10,
  114. res1Field = 11,
  115. res2Field = 12,
  116. res3Field = 13
  117. };
  118. typedef SInt8 DateForm;
  119. enum {
  120. shortDate = 0,
  121. longDate = 1,
  122. abbrevDate = 2
  123. };
  124. enum {
  125. /* StringToDate status values */
  126. fatalDateTime = 0x8000, /* StringToDate and String2Time mask to a fatal error */
  127. longDateFound = 1, /* StringToDate mask to long date found */
  128. leftOverChars = 2, /* StringToDate & Time mask to warn of left over characters */
  129. sepNotIntlSep = 4, /* StringToDate & Time mask to warn of non-standard separators */
  130. fieldOrderNotIntl = 8, /* StringToDate & Time mask to warn of non-standard field order */
  131. extraneousStrings = 16, /* StringToDate & Time mask to warn of unparsable strings in text */
  132. tooManySeps = 32, /* StringToDate & Time mask to warn of too many separators */
  133. sepNotConsistent = 64, /* StringToDate & Time mask to warn of inconsistent separators */
  134. tokenErr = 0x8100, /* StringToDate & Time mask for 'tokenizer err encountered' */
  135. cantReadUtilities = 0x8200,
  136. dateTimeNotFound = 0x8400,
  137. dateTimeInvalid = 0x8800
  138. };
  139. typedef short StringToDateStatus;
  140. typedef StringToDateStatus String2DateStatus;
  141. struct DateCacheRecord {
  142. short hidden[256]; /* only for temporary use */
  143. };
  144. typedef struct DateCacheRecord DateCacheRecord;
  145. typedef DateCacheRecord * DateCachePtr;
  146. struct DateTimeRec {
  147. short year;
  148. short month;
  149. short day;
  150. short hour;
  151. short minute;
  152. short second;
  153. short dayOfWeek;
  154. };
  155. typedef struct DateTimeRec DateTimeRec;
  156. typedef SInt64 LongDateTime;
  157. #if TARGET_RT_BIG_ENDIAN
  158. union LongDateCvt {
  159. SInt64 c;
  160. struct {
  161. UInt32 lHigh;
  162. UInt32 lLow;
  163. } hl;
  164. };
  165. typedef union LongDateCvt LongDateCvt;
  166. #else
  167. union LongDateCvt {
  168. SInt64 c;
  169. struct {
  170. UInt32 lLow;
  171. UInt32 lHigh;
  172. } hl;
  173. };
  174. typedef union LongDateCvt LongDateCvt;
  175. #endif /* TARGET_RT_BIG_ENDIAN */
  176. union LongDateRec {
  177. struct {
  178. short era;
  179. short year;
  180. short month;
  181. short day;
  182. short hour;
  183. short minute;
  184. short second;
  185. short dayOfWeek;
  186. short dayOfYear;
  187. short weekOfYear;
  188. short pm;
  189. short res1;
  190. short res2;
  191. short res3;
  192. } ld;
  193. short list[14]; /*Index by LongDateField!*/
  194. struct {
  195. short eraAlt;
  196. DateTimeRec oldDate;
  197. } od;
  198. };
  199. typedef union LongDateRec LongDateRec;
  200. typedef SInt8 DateDelta;
  201. struct TogglePB {
  202. long togFlags; /*caller normally sets low word to dateStdMask=$7F*/
  203. ResType amChars; /*from 'itl0', but uppercased*/
  204. ResType pmChars; /*from 'itl0', but uppercased*/
  205. long reserved[4];
  206. };
  207. typedef struct TogglePB TogglePB;
  208. /*
  209. Conversion utilities between CF and Carbon time types.
  210. */
  211. /*
  212. * UCConvertUTCDateTimeToCFAbsoluteTime()
  213. *
  214. * Discussion:
  215. * Use UCConvertUTCDateTimeToCFAbsoluteTime to convert from a
  216. * UTCDDateTime to a CFAbsoluteTime. Remember that the epoch for
  217. * UTCDateTime is January 1, 1904 while the epoch for CFAbsoluteTime
  218. * is January 1, 2001.
  219. *
  220. * Parameters:
  221. *
  222. * iUTCDate:
  223. * A pointer to a UTCDateTime struct that represents the time you
  224. * wish to convert from.
  225. *
  226. * oCFTime:
  227. * A pointer to a CFAbsoluteTime. On successful return, this will
  228. * contain the converted time from the input time type.
  229. *
  230. * Result:
  231. * A result code indicating whether or not conversion was successful.
  232. *
  233. * Availability:
  234. * Non-Carbon CFM: not available
  235. * CarbonLib: not available in CarbonLib 1.x
  236. * Mac OS X: in version 10.2 and later
  237. */
  238. EXTERN_API_C( OSStatus )
  239. UCConvertUTCDateTimeToCFAbsoluteTime(
  240. const UTCDateTime * iUTCDate,
  241. CFAbsoluteTime * oCFTime);
  242. /*
  243. * UCConvertSecondsToCFAbsoluteTime()
  244. *
  245. * Discussion:
  246. * Use UCConvertSecondsToCFAbsoluteTime to convert from the normal
  247. * seconds representation of time to a CFAbsoluteTime. Remember that
  248. * the epoch for seconds is January 1, 1904 while the epoch for
  249. * CFAbsoluteTime is January 1, 2001.
  250. *
  251. * Parameters:
  252. *
  253. * iSeconds:
  254. * A UInt32 value that represents the time you wish to convert
  255. * from.
  256. *
  257. * oCFTime:
  258. * A pointer to a CFAbsoluteTime. On successful return, this will
  259. * contain the converted time from the input time type.
  260. *
  261. * Result:
  262. * A result code indicating whether or not conversion was successful.
  263. *
  264. * Availability:
  265. * Non-Carbon CFM: not available
  266. * CarbonLib: not available in CarbonLib 1.x
  267. * Mac OS X: in version 10.2 and later
  268. */
  269. EXTERN_API_C( OSStatus )
  270. UCConvertSecondsToCFAbsoluteTime(
  271. UInt32 iSeconds,
  272. CFAbsoluteTime * oCFTime);
  273. /*
  274. * UCConvertLongDateTimeToCFAbsoluteTime()
  275. *
  276. * Discussion:
  277. * Use UCConvertLongDateTimeToCFAbsoluteTime to convert from a
  278. * LongDateTime to a CFAbsoluteTime. Remember that the epoch for
  279. * LongDateTime is January 1, 1904 while the epoch for
  280. * CFAbsoluteTime is January 1, 2001.
  281. *
  282. * Parameters:
  283. *
  284. * iLongTime:
  285. * A LongDateTime value that represents the time you wish to
  286. * convert from.
  287. *
  288. * oCFTime:
  289. * A pointer to a CFAbsoluteTime. On successful return, this will
  290. * contain the converted time from the input time type.
  291. *
  292. * Result:
  293. * A result code indicating whether or not conversion was successful.
  294. *
  295. * Availability:
  296. * Non-Carbon CFM: not available
  297. * CarbonLib: not available in CarbonLib 1.x
  298. * Mac OS X: in version 10.2 and later
  299. */
  300. EXTERN_API_C( OSStatus )
  301. UCConvertLongDateTimeToCFAbsoluteTime(
  302. LongDateTime iLongTime,
  303. CFAbsoluteTime * oCFTime);
  304. /*
  305. * UCConvertCFAbsoluteTimeToUTCDateTime()
  306. *
  307. * Discussion:
  308. * Use UCConvertCFAbsoluteTimeToUTCDateTime to convert from a
  309. * CFAbsoluteTime to a UTCDateTime. Remember that the epoch for
  310. * UTCDateTime is January 1, 1904 while the epoch for CFAbsoluteTime
  311. * is January 1, 2001.
  312. *
  313. * Parameters:
  314. *
  315. * iCFTime:
  316. * A CFAbsoluteTime value that represents the time you wish to
  317. * convert from.
  318. *
  319. * oUTCDate:
  320. * A pointer to a UTCDateTime. On successful return, this will
  321. * contain the converted time from the CFAbsoluteTime input.
  322. *
  323. * Result:
  324. * A result code indicating whether or not conversion was successful.
  325. *
  326. * Availability:
  327. * Non-Carbon CFM: not available
  328. * CarbonLib: not available in CarbonLib 1.x
  329. * Mac OS X: in version 10.2 and later
  330. */
  331. EXTERN_API_C( OSStatus )
  332. UCConvertCFAbsoluteTimeToUTCDateTime(
  333. CFAbsoluteTime iCFTime,
  334. UTCDateTime * oUTCDate);
  335. /*
  336. * UCConvertCFAbsoluteTimeToSeconds()
  337. *
  338. * Discussion:
  339. * Use UCConvertCFAbsoluteTimeToSeconds to convert from a
  340. * CFAbsoluteTime to a UInt32 representation of seconds. Remember
  341. * that the epoch for seconds is January 1, 1904 while the epoch for
  342. * CFAbsoluteTime is January 1, 2001.
  343. *
  344. * Parameters:
  345. *
  346. * iCFTime:
  347. * A CFAbsoluteTime value that represents the time you wish to
  348. * convert from.
  349. *
  350. * oSeconds:
  351. * A pointer to a UInt32. On successful return, this will contain
  352. * the converted time from the CFAbsoluteTime input.
  353. *
  354. * Result:
  355. * A result code indicating whether or not conversion was successful.
  356. *
  357. * Availability:
  358. * Non-Carbon CFM: not available
  359. * CarbonLib: not available in CarbonLib 1.x
  360. * Mac OS X: in version 10.2 and later
  361. */
  362. EXTERN_API_C( OSStatus )
  363. UCConvertCFAbsoluteTimeToSeconds(
  364. CFAbsoluteTime iCFTime,
  365. UInt32 * oSeconds);
  366. /*
  367. * UCConvertCFAbsoluteTimeToLongDateTime()
  368. *
  369. * Discussion:
  370. * Use UCConvertCFAbsoluteTimeToLongDateTime to convert from a
  371. * CFAbsoluteTime to a LongDateTime. Remember that the epoch for
  372. * LongDateTime is January 1, 1904 while the epoch for
  373. * CFAbsoluteTime is January 1, 2001.
  374. *
  375. * Parameters:
  376. *
  377. * iCFTime:
  378. * A CFAbsoluteTime value that represents the time you wish to
  379. * convert from.
  380. *
  381. * oLongDate:
  382. * A pointer to a LongDateTime. On successful return, this will
  383. * contain the converted time from the CFAbsoluteTime input.
  384. *
  385. * Result:
  386. * A result code indicating whether or not conversion was successful.
  387. *
  388. * Availability:
  389. * Non-Carbon CFM: not available
  390. * CarbonLib: not available in CarbonLib 1.x
  391. * Mac OS X: in version 10.2 and later
  392. */
  393. EXTERN_API_C( OSStatus )
  394. UCConvertCFAbsoluteTimeToLongDateTime(
  395. CFAbsoluteTime iCFTime,
  396. LongDateTime * oLongDate);
  397. /*
  398. These routine are available in Carbon with their new name
  399. */
  400. /*
  401. * DateString()
  402. *
  403. * Availability:
  404. * Non-Carbon CFM: not available
  405. * CarbonLib: in CarbonLib 1.0 and later
  406. * Mac OS X: in version 10.0 and later
  407. */
  408. EXTERN_API( void )
  409. DateString(
  410. long dateTime,
  411. DateForm longFlag,
  412. Str255 result,
  413. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x000E, 0xA9ED);
  414. /*
  415. * TimeString()
  416. *
  417. * Availability:
  418. * Non-Carbon CFM: not available
  419. * CarbonLib: in CarbonLib 1.0 and later
  420. * Mac OS X: in version 10.0 and later
  421. */
  422. EXTERN_API( void )
  423. TimeString(
  424. long dateTime,
  425. Boolean wantSeconds,
  426. Str255 result,
  427. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0010, 0xA9ED);
  428. /*
  429. * LongDateString()
  430. *
  431. * Availability:
  432. * Non-Carbon CFM: not available
  433. * CarbonLib: in CarbonLib 1.0 and later
  434. * Mac OS X: in version 10.0 and later
  435. */
  436. EXTERN_API( void )
  437. LongDateString(
  438. const LongDateTime * dateTime,
  439. DateForm longFlag,
  440. Str255 result,
  441. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0014, 0xA9ED);
  442. /*
  443. * LongTimeString()
  444. *
  445. * Availability:
  446. * Non-Carbon CFM: not available
  447. * CarbonLib: in CarbonLib 1.0 and later
  448. * Mac OS X: in version 10.0 and later
  449. */
  450. EXTERN_API( void )
  451. LongTimeString(
  452. const LongDateTime * dateTime,
  453. Boolean wantSeconds,
  454. Str255 result,
  455. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0016, 0xA9ED);
  456. /*
  457. These routine are available in Carbon and InterfaceLib with their new name
  458. */
  459. /*
  460. * InitDateCache()
  461. *
  462. * Availability:
  463. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  464. * CarbonLib: in CarbonLib 1.0 and later
  465. * Mac OS X: in version 10.0 and later
  466. */
  467. EXTERN_API( OSErr )
  468. InitDateCache(DateCachePtr theCache) FOURWORDINLINE(0x2F3C, 0x8204, 0xFFF8, 0xA8B5);
  469. /*
  470. * StringToDate()
  471. *
  472. * Availability:
  473. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  474. * CarbonLib: in CarbonLib 1.0 and later
  475. * Mac OS X: in version 10.0 and later
  476. */
  477. EXTERN_API( StringToDateStatus )
  478. StringToDate(
  479. Ptr textPtr,
  480. long textLen,
  481. DateCachePtr theCache,
  482. long * lengthUsed,
  483. LongDateRec * dateTime) FOURWORDINLINE(0x2F3C, 0x8214, 0xFFF6, 0xA8B5);
  484. /*
  485. * StringToTime()
  486. *
  487. * Availability:
  488. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  489. * CarbonLib: in CarbonLib 1.0 and later
  490. * Mac OS X: in version 10.0 and later
  491. */
  492. EXTERN_API( StringToDateStatus )
  493. StringToTime(
  494. Ptr textPtr,
  495. long textLen,
  496. DateCachePtr theCache,
  497. long * lengthUsed,
  498. LongDateRec * dateTime) FOURWORDINLINE(0x2F3C, 0x8214, 0xFFF4, 0xA8B5);
  499. /*
  500. * LongDateToSeconds()
  501. *
  502. * Availability:
  503. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  504. * CarbonLib: in CarbonLib 1.0 and later
  505. * Mac OS X: in version 10.0 and later
  506. */
  507. EXTERN_API( void )
  508. LongDateToSeconds(
  509. const LongDateRec * lDate,
  510. LongDateTime * lSecs) FOURWORDINLINE(0x2F3C, 0x8008, 0xFFF2, 0xA8B5);
  511. /*
  512. * LongSecondsToDate()
  513. *
  514. * Availability:
  515. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  516. * CarbonLib: in CarbonLib 1.0 and later
  517. * Mac OS X: in version 10.0 and later
  518. */
  519. EXTERN_API( void )
  520. LongSecondsToDate(
  521. const LongDateTime * lSecs,
  522. LongDateRec * lDate) FOURWORDINLINE(0x2F3C, 0x8008, 0xFFF0, 0xA8B5);
  523. /*
  524. * ToggleDate()
  525. *
  526. * Availability:
  527. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  528. * CarbonLib: in CarbonLib 1.0 and later
  529. * Mac OS X: in version 10.0 and later
  530. */
  531. EXTERN_API( ToggleResults )
  532. ToggleDate(
  533. LongDateTime * lSecs,
  534. LongDateField field,
  535. DateDelta delta,
  536. short ch,
  537. const TogglePB * params) FOURWORDINLINE(0x2F3C, 0x820E, 0xFFEE, 0xA8B5);
  538. /*
  539. * ValidDate()
  540. *
  541. * Availability:
  542. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  543. * CarbonLib: in CarbonLib 1.0 and later
  544. * Mac OS X: in version 10.0 and later
  545. */
  546. EXTERN_API( short )
  547. ValidDate(
  548. const LongDateRec * vDate,
  549. long flags,
  550. LongDateTime * newSecs) FOURWORDINLINE(0x2F3C, 0x820C, 0xFFE4, 0xA8B5);
  551. /*
  552. * ReadDateTime()
  553. *
  554. * Availability:
  555. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  556. * CarbonLib: in CarbonLib 1.0 and later
  557. * Mac OS X: in version 10.0 and later
  558. */
  559. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  560. #pragma parameter __D0 ReadDateTime(__A0)
  561. #endif
  562. EXTERN_API( OSErr )
  563. ReadDateTime(unsigned long * time) ONEWORDINLINE(0xA039);
  564. /*
  565. * GetDateTime()
  566. *
  567. * Availability:
  568. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  569. * CarbonLib: in CarbonLib 1.0 and later
  570. * Mac OS X: in version 10.0 and later
  571. */
  572. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  573. #pragma parameter GetDateTime(__A0)
  574. #endif
  575. EXTERN_API( void )
  576. GetDateTime(unsigned long * secs) TWOWORDINLINE(0x20B8, 0x020C);
  577. /*
  578. * SetDateTime()
  579. *
  580. * Availability:
  581. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  582. * CarbonLib: in CarbonLib 1.0 and later
  583. * Mac OS X: in version 10.0 and later
  584. */
  585. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  586. #pragma parameter __D0 SetDateTime(__D0)
  587. #endif
  588. EXTERN_API( OSErr )
  589. SetDateTime(unsigned long time) ONEWORDINLINE(0xA03A);
  590. /*
  591. * SetTime()
  592. *
  593. * Availability:
  594. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  595. * CarbonLib: in CarbonLib 1.0 and later
  596. * Mac OS X: in version 10.0 and later
  597. */
  598. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  599. #pragma parameter SetTime(__A0)
  600. #endif
  601. EXTERN_API( void )
  602. SetTime(const DateTimeRec * d) TWOWORDINLINE(0xA9C7, 0xA03A);
  603. /*
  604. * GetTime()
  605. *
  606. * Availability:
  607. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  608. * CarbonLib: in CarbonLib 1.0 and later
  609. * Mac OS X: in version 10.0 and later
  610. */
  611. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  612. #pragma parameter GetTime(__A0)
  613. #endif
  614. EXTERN_API( void )
  615. GetTime(DateTimeRec * d) THREEWORDINLINE(0x2038, 0x020C, 0xA9C6);
  616. /*
  617. * DateToSeconds()
  618. *
  619. * Availability:
  620. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  621. * CarbonLib: in CarbonLib 1.0 and later
  622. * Mac OS X: in version 10.0 and later
  623. */
  624. EXTERN_API( void )
  625. DateToSeconds(
  626. const DateTimeRec * d,
  627. unsigned long * secs);
  628. /*
  629. * SecondsToDate()
  630. *
  631. * Availability:
  632. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  633. * CarbonLib: in CarbonLib 1.0 and later
  634. * Mac OS X: in version 10.0 and later
  635. */
  636. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  637. #pragma parameter SecondsToDate(__D0, __A0)
  638. #endif
  639. EXTERN_API( void )
  640. SecondsToDate(
  641. unsigned long secs,
  642. DateTimeRec * d) ONEWORDINLINE(0xA9C6);
  643. /*
  644. These routine are available in InterfaceLib using their old name.
  645. Macros allow using the new names in all source code.
  646. */
  647. #if CALL_NOT_IN_CARBON
  648. /*
  649. * IUDateString()
  650. *
  651. * Availability:
  652. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  653. * CarbonLib: not available
  654. * Mac OS X: not available
  655. */
  656. EXTERN_API( void )
  657. IUDateString(
  658. long dateTime,
  659. DateForm longFlag,
  660. Str255 result) TWOWORDINLINE(0x4267, 0xA9ED);
  661. /*
  662. * IUTimeString()
  663. *
  664. * Availability:
  665. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  666. * CarbonLib: not available
  667. * Mac OS X: not available
  668. */
  669. EXTERN_API( void )
  670. IUTimeString(
  671. long dateTime,
  672. Boolean wantSeconds,
  673. Str255 result) THREEWORDINLINE(0x3F3C, 0x0002, 0xA9ED);
  674. /*
  675. * IUDatePString()
  676. *
  677. * Availability:
  678. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  679. * CarbonLib: not available
  680. * Mac OS X: not available
  681. */
  682. EXTERN_API( void )
  683. IUDatePString(
  684. long dateTime,
  685. DateForm longFlag,
  686. Str255 result,
  687. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x000E, 0xA9ED);
  688. /*
  689. * IUTimePString()
  690. *
  691. * Availability:
  692. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  693. * CarbonLib: not available
  694. * Mac OS X: not available
  695. */
  696. EXTERN_API( void )
  697. IUTimePString(
  698. long dateTime,
  699. Boolean wantSeconds,
  700. Str255 result,
  701. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0010, 0xA9ED);
  702. /*
  703. * IULDateString()
  704. *
  705. * Availability:
  706. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  707. * CarbonLib: not available
  708. * Mac OS X: not available
  709. */
  710. EXTERN_API( void )
  711. IULDateString(
  712. LongDateTime * dateTime,
  713. DateForm longFlag,
  714. Str255 result,
  715. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0014, 0xA9ED);
  716. /*
  717. * IULTimeString()
  718. *
  719. * Availability:
  720. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  721. * CarbonLib: not available
  722. * Mac OS X: not available
  723. */
  724. EXTERN_API( void )
  725. IULTimeString(
  726. LongDateTime * dateTime,
  727. Boolean wantSeconds,
  728. Str255 result,
  729. Handle intlHandle) THREEWORDINLINE(0x3F3C, 0x0016, 0xA9ED);
  730. #endif /* CALL_NOT_IN_CARBON */
  731. #if CALL_NOT_IN_CARBON
  732. #define DateString(dateTime, longFlag, result, intlHandle) \
  733. IUDatePString( dateTime, longFlag, result, intlHandle)
  734. #define TimeString(dateTime, wantSeconds, result, intlHandle) \
  735. IUTimePString(dateTime, wantSeconds, result, intlHandle)
  736. #define LongDateString(dateTime, longFlag, result, intlHandle) \
  737. IULDateString(dateTime, longFlag, result, intlHandle)
  738. #define LongTimeString(dateTime, wantSeconds, result, intlHandle) \
  739. IULTimeString(dateTime, wantSeconds, result, intlHandle)
  740. #endif /* CALL_NOT_IN_CARBON */
  741. #if OLDROUTINENAMES
  742. #define String2Date(textPtr, textLen, theCache, lengthUsed, dateTime) \
  743. StringToDate(textPtr, textLen, theCache, lengthUsed, dateTime)
  744. #define String2Time(textPtr, textLen, theCache, lengthUsed, dateTime) \
  745. StringToTime(textPtr, textLen, theCache, lengthUsed, dateTime)
  746. #define LongDate2Secs(lDate, lSecs) LongDateToSeconds(lDate, lSecs)
  747. #define LongSecs2Date(lSecs, lDate) LongSecondsToDate(lSecs, lDate)
  748. #define Date2Secs(d, secs) DateToSeconds(d, secs)
  749. #define Secs2Date(secs, d) SecondsToDate(secs, d)
  750. #endif /* OLDROUTINENAMES */
  751. #if CALL_NOT_IN_CARBON
  752. /*
  753. * iudatestring()
  754. *
  755. * Availability:
  756. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  757. * CarbonLib: not available
  758. * Mac OS X: not available
  759. */
  760. EXTERN_API_C( void )
  761. iudatestring(
  762. long dateTime,
  763. DateForm longFlag,
  764. char * result);
  765. /*
  766. * iudatepstring()
  767. *
  768. * Availability:
  769. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  770. * CarbonLib: not available
  771. * Mac OS X: not available
  772. */
  773. EXTERN_API_C( void )
  774. iudatepstring(
  775. long dateTime,
  776. DateForm longFlag,
  777. char * result,
  778. Handle intlHandle);
  779. /*
  780. * iutimestring()
  781. *
  782. * Availability:
  783. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  784. * CarbonLib: not available
  785. * Mac OS X: not available
  786. */
  787. EXTERN_API_C( void )
  788. iutimestring(
  789. long dateTime,
  790. Boolean wantSeconds,
  791. char * result);
  792. /*
  793. * iutimepstring()
  794. *
  795. * Availability:
  796. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  797. * CarbonLib: not available
  798. * Mac OS X: not available
  799. */
  800. EXTERN_API_C( void )
  801. iutimepstring(
  802. long dateTime,
  803. Boolean wantSeconds,
  804. char * result,
  805. Handle intlHandle);
  806. /*
  807. * iuldatestring()
  808. *
  809. * Availability:
  810. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  811. * CarbonLib: not available
  812. * Mac OS X: not available
  813. */
  814. EXTERN_API_C( void )
  815. iuldatestring(
  816. LongDateTime * dateTime,
  817. DateForm longFlag,
  818. char * result,
  819. Handle intlHandle);
  820. /*
  821. * iultimestring()
  822. *
  823. * Availability:
  824. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  825. * CarbonLib: not available
  826. * Mac OS X: not available
  827. */
  828. EXTERN_API_C( void )
  829. iultimestring(
  830. LongDateTime * dateTime,
  831. Boolean wantSeconds,
  832. char * result,
  833. Handle intlHandle);
  834. #endif /* CALL_NOT_IN_CARBON */
  835. #if PRAGMA_STRUCT_ALIGN
  836. #pragma options align=reset
  837. #elif PRAGMA_STRUCT_PACKPUSH
  838. #pragma pack(pop)
  839. #elif PRAGMA_STRUCT_PACK
  840. #pragma pack()
  841. #endif
  842. #ifdef PRAGMA_IMPORT_OFF
  843. #pragma import off
  844. #elif PRAGMA_IMPORT
  845. #pragma import reset
  846. #endif
  847. #ifdef __cplusplus
  848. }
  849. #endif
  850. #endif /* __DATETIMEUTILS__ */