DateTimeUtils.pas 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. {
  2. File: CarbonCore/DateTimeUtils.h
  3. Contains: International Date and Time Interfaces (previously in TextUtils)
  4. Copyright: © 1994-2011 by Apple Inc. All rights reserved.
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. {
  10. Modified for use with Free Pascal
  11. Version 308
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  15. {$mode macpas}
  16. {$modeswitch cblocks}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$calling mwpascal}
  21. {$IFNDEF FPC_DOTTEDUNITS}
  22. unit DateTimeUtils;
  23. {$ENDIF FPC_DOTTEDUNITS}
  24. interface
  25. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  26. {$setc GAP_INTERFACES_VERSION := $0308}
  27. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  28. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  29. {$endc}
  30. {$ifc defined CPUPOWERPC and defined CPUI386}
  31. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  32. {$endc}
  33. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  34. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  35. {$endc}
  36. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  37. {$setc __ppc__ := 1}
  38. {$elsec}
  39. {$setc __ppc__ := 0}
  40. {$endc}
  41. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  42. {$setc __ppc64__ := 1}
  43. {$elsec}
  44. {$setc __ppc64__ := 0}
  45. {$endc}
  46. {$ifc not defined __i386__ and defined CPUI386}
  47. {$setc __i386__ := 1}
  48. {$elsec}
  49. {$setc __i386__ := 0}
  50. {$endc}
  51. {$ifc not defined __x86_64__ and defined CPUX86_64}
  52. {$setc __x86_64__ := 1}
  53. {$elsec}
  54. {$setc __x86_64__ := 0}
  55. {$endc}
  56. {$ifc not defined __arm__ and defined CPUARM}
  57. {$setc __arm__ := 1}
  58. {$elsec}
  59. {$setc __arm__ := 0}
  60. {$endc}
  61. {$ifc not defined __arm64__ and defined CPUAARCH64}
  62. {$setc __arm64__ := 1}
  63. {$elsec}
  64. {$setc __arm64__ := 0}
  65. {$endc}
  66. {$ifc defined cpu64}
  67. {$setc __LP64__ := 1}
  68. {$elsec}
  69. {$setc __LP64__ := 0}
  70. {$endc}
  71. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  72. {$error Conflicting definitions for __ppc__ and __i386__}
  73. {$endc}
  74. {$ifc defined __ppc__ and __ppc__}
  75. {$setc TARGET_CPU_PPC := TRUE}
  76. {$setc TARGET_CPU_PPC64 := FALSE}
  77. {$setc TARGET_CPU_X86 := FALSE}
  78. {$setc TARGET_CPU_X86_64 := FALSE}
  79. {$setc TARGET_CPU_ARM := FALSE}
  80. {$setc TARGET_CPU_ARM64 := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_IPHONE := FALSE}
  83. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  84. {$setc TARGET_OS_EMBEDDED := FALSE}
  85. {$elifc defined __ppc64__ and __ppc64__}
  86. {$setc TARGET_CPU_PPC := FALSE}
  87. {$setc TARGET_CPU_PPC64 := TRUE}
  88. {$setc TARGET_CPU_X86 := FALSE}
  89. {$setc TARGET_CPU_X86_64 := FALSE}
  90. {$setc TARGET_CPU_ARM := FALSE}
  91. {$setc TARGET_CPU_ARM64 := FALSE}
  92. {$setc TARGET_OS_MAC := TRUE}
  93. {$setc TARGET_OS_IPHONE := FALSE}
  94. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  95. {$setc TARGET_OS_EMBEDDED := FALSE}
  96. {$elifc defined __i386__ and __i386__}
  97. {$setc TARGET_CPU_PPC := FALSE}
  98. {$setc TARGET_CPU_PPC64 := FALSE}
  99. {$setc TARGET_CPU_X86 := TRUE}
  100. {$setc TARGET_CPU_X86_64 := FALSE}
  101. {$setc TARGET_CPU_ARM := FALSE}
  102. {$setc TARGET_CPU_ARM64 := FALSE}
  103. {$ifc defined iphonesim}
  104. {$setc TARGET_OS_MAC := FALSE}
  105. {$setc TARGET_OS_IPHONE := TRUE}
  106. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  107. {$elsec}
  108. {$setc TARGET_OS_MAC := TRUE}
  109. {$setc TARGET_OS_IPHONE := FALSE}
  110. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  111. {$endc}
  112. {$setc TARGET_OS_EMBEDDED := FALSE}
  113. {$elifc defined __x86_64__ and __x86_64__}
  114. {$setc TARGET_CPU_PPC := FALSE}
  115. {$setc TARGET_CPU_PPC64 := FALSE}
  116. {$setc TARGET_CPU_X86 := FALSE}
  117. {$setc TARGET_CPU_X86_64 := TRUE}
  118. {$setc TARGET_CPU_ARM := FALSE}
  119. {$setc TARGET_CPU_ARM64 := FALSE}
  120. {$ifc defined iphonesim}
  121. {$setc TARGET_OS_MAC := FALSE}
  122. {$setc TARGET_OS_IPHONE := TRUE}
  123. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  124. {$elsec}
  125. {$setc TARGET_OS_MAC := TRUE}
  126. {$setc TARGET_OS_IPHONE := FALSE}
  127. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  128. {$endc}
  129. {$setc TARGET_OS_EMBEDDED := FALSE}
  130. {$elifc defined __arm__ and __arm__}
  131. {$setc TARGET_CPU_PPC := FALSE}
  132. {$setc TARGET_CPU_PPC64 := FALSE}
  133. {$setc TARGET_CPU_X86 := FALSE}
  134. {$setc TARGET_CPU_X86_64 := FALSE}
  135. {$setc TARGET_CPU_ARM := TRUE}
  136. {$setc TARGET_CPU_ARM64 := FALSE}
  137. {$setc TARGET_OS_MAC := FALSE}
  138. {$setc TARGET_OS_IPHONE := TRUE}
  139. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  140. {$setc TARGET_OS_EMBEDDED := TRUE}
  141. {$elifc defined __arm64__ and __arm64__}
  142. {$setc TARGET_CPU_PPC := FALSE}
  143. {$setc TARGET_CPU_PPC64 := FALSE}
  144. {$setc TARGET_CPU_X86 := FALSE}
  145. {$setc TARGET_CPU_X86_64 := FALSE}
  146. {$setc TARGET_CPU_ARM := FALSE}
  147. {$setc TARGET_CPU_ARM64 := TRUE}
  148. {$ifc defined ios}
  149. {$setc TARGET_OS_MAC := FALSE}
  150. {$setc TARGET_OS_IPHONE := TRUE}
  151. {$setc TARGET_OS_EMBEDDED := TRUE}
  152. {$elsec}
  153. {$setc TARGET_OS_MAC := TRUE}
  154. {$setc TARGET_OS_IPHONE := FALSE}
  155. {$setc TARGET_OS_EMBEDDED := FALSE}
  156. {$endc}
  157. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  158. {$elsec}
  159. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  160. {$endc}
  161. {$ifc defined __LP64__ and __LP64__ }
  162. {$setc TARGET_CPU_64 := TRUE}
  163. {$elsec}
  164. {$setc TARGET_CPU_64 := FALSE}
  165. {$endc}
  166. {$ifc defined FPC_BIG_ENDIAN}
  167. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  168. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  169. {$elifc defined FPC_LITTLE_ENDIAN}
  170. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  171. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  172. {$elsec}
  173. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  174. {$endc}
  175. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  176. {$setc CALL_NOT_IN_CARBON := FALSE}
  177. {$setc OLDROUTINENAMES := FALSE}
  178. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  179. {$setc OPAQUE_UPP_TYPES := TRUE}
  180. {$setc OTCARBONAPPLICATION := TRUE}
  181. {$setc OTKERNEL := FALSE}
  182. {$setc PM_USE_SESSION_APIS := TRUE}
  183. {$setc TARGET_API_MAC_CARBON := TRUE}
  184. {$setc TARGET_API_MAC_OS8 := FALSE}
  185. {$setc TARGET_API_MAC_OSX := TRUE}
  186. {$setc TARGET_CARBON := TRUE}
  187. {$setc TARGET_CPU_68K := FALSE}
  188. {$setc TARGET_CPU_MIPS := FALSE}
  189. {$setc TARGET_CPU_SPARC := FALSE}
  190. {$setc TARGET_OS_UNIX := FALSE}
  191. {$setc TARGET_OS_WIN32 := FALSE}
  192. {$setc TARGET_RT_MAC_68881 := FALSE}
  193. {$setc TARGET_RT_MAC_CFM := FALSE}
  194. {$setc TARGET_RT_MAC_MACHO := TRUE}
  195. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  196. {$setc TYPE_BOOL := FALSE}
  197. {$setc TYPE_EXTENDED := FALSE}
  198. {$setc TYPE_LONGLONG := TRUE}
  199. {$IFDEF FPC_DOTTEDUNITS}
  200. uses MacOsApi.MacTypes,MacOsApi.UTCUtils,MacOsApi.CFDate;
  201. {$ELSE FPC_DOTTEDUNITS}
  202. uses MacTypes,UTCUtils,CFDate;
  203. {$ENDIF FPC_DOTTEDUNITS}
  204. {$endc} {not MACOSALLINCLUDE}
  205. {$ifc TARGET_OS_MAC}
  206. {$ALIGN MAC68K}
  207. {
  208. Here are the current routine names and the translations to the older forms.
  209. Please use the newer forms in all new code and migrate the older names out of existing
  210. code as maintainance permits.
  211. New Name Old Name(s)
  212. DateString IUDatePString IUDateString
  213. InitDateCache
  214. LongDateString IULDateString
  215. LongTimeString IULTimeString
  216. StringToDate String2Date
  217. StringToTime
  218. TimeString IUTimeString IUTimePString
  219. LongDateToSeconds LongDate2Secs
  220. LongSecondsToDate LongSecs2Date
  221. DateToSeconds Date2Secs
  222. SecondsToDate Secs2Date
  223. Carbon only supports the new names. The old names are undefined for Carbon targets.
  224. This is true for C, Assembly and Pascal.
  225. InterfaceLib always has exported the old names. For C macros have been defined to allow
  226. the use of the new names. For Pascal and Assembly using the new names will result
  227. in link errors.
  228. }
  229. type
  230. ToggleResults = SInt16;
  231. const
  232. { Toggle results }
  233. toggleUndefined = 0;
  234. toggleOK = 1;
  235. toggleBadField = 2;
  236. toggleBadDelta = 3;
  237. toggleBadChar = 4;
  238. toggleUnknown = 5;
  239. toggleBadNum = 6;
  240. toggleOutOfRange = 7; {synonym for toggleErr3}
  241. toggleErr3 = 7;
  242. toggleErr4 = 8;
  243. toggleErr5 = 9;
  244. const
  245. { Date equates }
  246. smallDateBit = 31; {Restrict valid date/time to range of Time global}
  247. togChar12HourBit = 30; {If toggling hour by AnsiChar, accept hours 1..12 only}
  248. togCharZCycleBit = 29; {Modifier for togChar12HourBit: accept hours 0..11 only}
  249. togDelta12HourBit = 28; {If toggling hour up/down, restrict to 12-hour range (am/pm)}
  250. genCdevRangeBit = 27; {Restrict date/time to range used by genl CDEV}
  251. validDateFields = -1;
  252. maxDateField = 10;
  253. const
  254. eraMask = $0001;
  255. yearMask = $0002;
  256. monthMask = $0004;
  257. dayMask = $0008;
  258. hourMask = $0010;
  259. minuteMask = $0020;
  260. secondMask = $0040;
  261. dayOfWeekMask = $0080;
  262. dayOfYearMask = $0100;
  263. weekOfYearMask = $0200;
  264. pmMask = $0400;
  265. dateStdMask = $007F; {default for ValidDate flags and ToggleDate TogglePB.togFlags}
  266. type
  267. LongDateField = SInt8;
  268. const
  269. eraField = 0;
  270. yearField = 1;
  271. monthField = 2;
  272. dayField = 3;
  273. hourField = 4;
  274. minuteField = 5;
  275. secondField = 6;
  276. dayOfWeekField = 7;
  277. dayOfYearField = 8;
  278. weekOfYearField = 9;
  279. pmField = 10;
  280. res1Field = 11;
  281. res2Field = 12;
  282. res3Field = 13;
  283. type
  284. DateForm = SInt8;
  285. const
  286. shortDate = 0;
  287. longDate = 1;
  288. abbrevDate = 2;
  289. const
  290. { StringToDate status values }
  291. fatalDateTime = $8000; { StringToDate and String2Time mask to a fatal error }
  292. longDateFound = 1; { StringToDate mask to long date found }
  293. leftOverChars = 2; { StringToDate & Time mask to warn of left over characters }
  294. sepNotIntlSep = 4; { StringToDate & Time mask to warn of non-standard separators }
  295. fieldOrderNotIntl = 8; { StringToDate & Time mask to warn of non-standard field order }
  296. extraneousStrings = 16; { StringToDate & Time mask to warn of unparsable strings in text }
  297. tooManySeps = 32; { StringToDate & Time mask to warn of too many separators }
  298. sepNotConsistent = 64; { StringToDate & Time mask to warn of inconsistent separators }
  299. tokenErr = $8100; { StringToDate & Time mask for 'tokenizer err encountered' }
  300. cantReadUtilities = $8200;
  301. dateTimeNotFound = $8400;
  302. dateTimeInvalid = $8800;
  303. type
  304. StringToDateStatus = SInt16;
  305. String2DateStatus = StringToDateStatus;
  306. DateCacheRecordPtr = ^DateCacheRecord;
  307. DateCacheRecord = packed record
  308. hidden: array [0..255] of SInt16; { only for temporary use }
  309. end;
  310. type
  311. DateCachePtr = DateCacheRecordPtr;
  312. DateTimeRecPtr = ^DateTimeRec;
  313. DateTimeRec = record
  314. year: SInt16;
  315. month: SInt16;
  316. day: SInt16;
  317. hour: SInt16;
  318. minute: SInt16;
  319. second: SInt16;
  320. dayOfWeek: SInt16;
  321. end;
  322. type
  323. LongDateTime = SInt64;
  324. LongDateTimePtr = ^LongDateTime;
  325. {$ifc TARGET_RT_BIG_ENDIAN}
  326. LongDateCvt = record
  327. case SInt16 of
  328. 0: (
  329. c: SInt64;
  330. );
  331. 1: (
  332. lHigh: UInt32;
  333. lLow: UInt32;
  334. );
  335. end;
  336. {$elsec}
  337. LongDateCvt = record
  338. case SInt16 of
  339. 0: (
  340. c: SInt64;
  341. );
  342. 1: (
  343. lLow: UInt32;
  344. lHigh: UInt32;
  345. );
  346. end;
  347. {$endc}
  348. LongDateCvtPtr = ^LongDateCvt;
  349. LongDateRecPtr = ^LongDateRec;
  350. LongDateRec = record
  351. case SInt16 of
  352. 0: (
  353. era: SInt16;
  354. year: SInt16;
  355. month: SInt16;
  356. day: SInt16;
  357. hour: SInt16;
  358. minute: SInt16;
  359. second: SInt16;
  360. dayOfWeek: SInt16;
  361. dayOfYear: SInt16;
  362. weekOfYear: SInt16;
  363. pm: SInt16;
  364. res1: SInt16;
  365. res2: SInt16;
  366. res3: SInt16;
  367. );
  368. 1: (
  369. list: array [0..13] of SInt16; {Index by LongDateField!}
  370. );
  371. 2: (
  372. eraAlt: SInt16;
  373. oldDate: DateTimeRec;
  374. );
  375. end;
  376. type
  377. DateDelta = SInt8;
  378. TogglePBPtr = ^TogglePB;
  379. TogglePB = record
  380. togFlags: SIGNEDLONG; {caller normally sets low word to dateStdMask=$7F}
  381. amChars: ResType; {from 'itl0', but uppercased}
  382. pmChars: ResType; {from 'itl0', but uppercased}
  383. reserved: array [0..3] of SInt32;
  384. end;
  385. {
  386. Conversion utilities between CF and Carbon time types.
  387. }
  388. {
  389. * UCConvertUTCDateTimeToCFAbsoluteTime()
  390. *
  391. * Discussion:
  392. * Use UCConvertUTCDateTimeToCFAbsoluteTime to convert from a
  393. * UTCDDateTime to a CFAbsoluteTime. Remember that the epoch for
  394. * UTCDateTime is January 1, 1904 while the epoch for CFAbsoluteTime
  395. * is January 1, 2001.
  396. *
  397. * Parameters:
  398. *
  399. * iUTCDate:
  400. * A pointer to a UTCDateTime struct that represents the time you
  401. * wish to convert from.
  402. *
  403. * oCFTime:
  404. * A pointer to a CFAbsoluteTime. On successful return, this will
  405. * contain the converted time from the input time type.
  406. *
  407. * Result:
  408. * A result code indicating whether or not conversion was successful.
  409. *
  410. * Availability:
  411. * Mac OS X: in version 10.2 and later in CoreServices.framework
  412. * CarbonLib: not available in CarbonLib 1.x
  413. * Non-Carbon CFM: not available
  414. }
  415. function UCConvertUTCDateTimeToCFAbsoluteTime( const (*var*) iUTCDate: UTCDateTime; var oCFTime: CFAbsoluteTime ): OSStatus; external name '_UCConvertUTCDateTimeToCFAbsoluteTime';
  416. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  417. {
  418. * UCConvertSecondsToCFAbsoluteTime()
  419. *
  420. * Discussion:
  421. * Use UCConvertSecondsToCFAbsoluteTime to convert from the normal
  422. * seconds representation of time to a CFAbsoluteTime. Remember that
  423. * the epoch for seconds is January 1, 1904 while the epoch for
  424. * CFAbsoluteTime is January 1, 2001.
  425. *
  426. * Parameters:
  427. *
  428. * iSeconds:
  429. * A UInt32 value that represents the time you wish to convert
  430. * from.
  431. *
  432. * oCFTime:
  433. * A pointer to a CFAbsoluteTime. On successful return, this will
  434. * contain the converted time from the input time type.
  435. *
  436. * Result:
  437. * A result code indicating whether or not conversion was successful.
  438. *
  439. * Availability:
  440. * Mac OS X: in version 10.2 and later in CoreServices.framework
  441. * CarbonLib: not available in CarbonLib 1.x
  442. * Non-Carbon CFM: not available
  443. }
  444. function UCConvertSecondsToCFAbsoluteTime( iSeconds: UInt32; var oCFTime: CFAbsoluteTime ): OSStatus; external name '_UCConvertSecondsToCFAbsoluteTime';
  445. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  446. {
  447. * UCConvertLongDateTimeToCFAbsoluteTime()
  448. *
  449. * Discussion:
  450. * Use UCConvertLongDateTimeToCFAbsoluteTime to convert from a
  451. * LongDateTime to a CFAbsoluteTime. Remember that the epoch for
  452. * LongDateTime is January 1, 1904 while the epoch for
  453. * CFAbsoluteTime is January 1, 2001.
  454. *
  455. * Parameters:
  456. *
  457. * iLongTime:
  458. * A LongDateTime value that represents the time you wish to
  459. * convert from.
  460. *
  461. * oCFTime:
  462. * A pointer to a CFAbsoluteTime. On successful return, this will
  463. * contain the converted time from the input time type.
  464. *
  465. * Result:
  466. * A result code indicating whether or not conversion was successful.
  467. *
  468. * Availability:
  469. * Mac OS X: in version 10.2 and later in CoreServices.framework
  470. * CarbonLib: not available in CarbonLib 1.x
  471. * Non-Carbon CFM: not available
  472. }
  473. function UCConvertLongDateTimeToCFAbsoluteTime( iLongTime: LongDateTime; var oCFTime: CFAbsoluteTime ): OSStatus; external name '_UCConvertLongDateTimeToCFAbsoluteTime';
  474. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  475. {
  476. * UCConvertCFAbsoluteTimeToUTCDateTime()
  477. *
  478. * Discussion:
  479. * Use UCConvertCFAbsoluteTimeToUTCDateTime to convert from a
  480. * CFAbsoluteTime to a UTCDateTime. Remember that the epoch for
  481. * UTCDateTime is January 1, 1904 while the epoch for CFAbsoluteTime
  482. * is January 1, 2001.
  483. *
  484. * Parameters:
  485. *
  486. * iCFTime:
  487. * A CFAbsoluteTime value that represents the time you wish to
  488. * convert from.
  489. *
  490. * oUTCDate:
  491. * A pointer to a UTCDateTime. On successful return, this will
  492. * contain the converted time from the CFAbsoluteTime input.
  493. *
  494. * Result:
  495. * A result code indicating whether or not conversion was successful.
  496. *
  497. * Availability:
  498. * Mac OS X: in version 10.2 and later in CoreServices.framework
  499. * CarbonLib: not available in CarbonLib 1.x
  500. * Non-Carbon CFM: not available
  501. }
  502. function UCConvertCFAbsoluteTimeToUTCDateTime( iCFTime: CFAbsoluteTime; var oUTCDate: UTCDateTime ): OSStatus; external name '_UCConvertCFAbsoluteTimeToUTCDateTime';
  503. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  504. {
  505. * UCConvertCFAbsoluteTimeToSeconds()
  506. *
  507. * Discussion:
  508. * Use UCConvertCFAbsoluteTimeToSeconds to convert from a
  509. * CFAbsoluteTime to a UInt32 representation of seconds. Remember
  510. * that the epoch for seconds is January 1, 1904 while the epoch for
  511. * CFAbsoluteTime is January 1, 2001.
  512. *
  513. * Parameters:
  514. *
  515. * iCFTime:
  516. * A CFAbsoluteTime value that represents the time you wish to
  517. * convert from.
  518. *
  519. * oSeconds:
  520. * A pointer to a UInt32. On successful return, this will contain
  521. * the converted time from the CFAbsoluteTime input.
  522. *
  523. * Result:
  524. * A result code indicating whether or not conversion was successful.
  525. *
  526. * Availability:
  527. * Mac OS X: in version 10.2 and later in CoreServices.framework
  528. * CarbonLib: not available in CarbonLib 1.x
  529. * Non-Carbon CFM: not available
  530. }
  531. function UCConvertCFAbsoluteTimeToSeconds( iCFTime: CFAbsoluteTime; var oSeconds: UInt32 ): OSStatus; external name '_UCConvertCFAbsoluteTimeToSeconds';
  532. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  533. {
  534. * UCConvertCFAbsoluteTimeToLongDateTime()
  535. *
  536. * Discussion:
  537. * Use UCConvertCFAbsoluteTimeToLongDateTime to convert from a
  538. * CFAbsoluteTime to a LongDateTime. Remember that the epoch for
  539. * LongDateTime is January 1, 1904 while the epoch for
  540. * CFAbsoluteTime is January 1, 2001.
  541. *
  542. * Parameters:
  543. *
  544. * iCFTime:
  545. * A CFAbsoluteTime value that represents the time you wish to
  546. * convert from.
  547. *
  548. * oLongDate:
  549. * A pointer to a LongDateTime. On successful return, this will
  550. * contain the converted time from the CFAbsoluteTime input.
  551. *
  552. * Result:
  553. * A result code indicating whether or not conversion was successful.
  554. *
  555. * Availability:
  556. * Mac OS X: in version 10.2 and later in CoreServices.framework
  557. * CarbonLib: not available in CarbonLib 1.x
  558. * Non-Carbon CFM: not available
  559. }
  560. function UCConvertCFAbsoluteTimeToLongDateTime( iCFTime: CFAbsoluteTime; var oLongDate: LongDateTime ): OSStatus; external name '_UCConvertCFAbsoluteTimeToLongDateTime';
  561. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  562. {$ifc not TARGET_CPU_64}
  563. {
  564. These routine are available in Carbon with their new name
  565. }
  566. {$ifc not TARGET_CPU_64}
  567. {
  568. * DateString() *** DEPRECATED ***
  569. *
  570. * Deprecated:
  571. * use CFDateFormatterCreateStringWithDate instead
  572. *
  573. * Discussion:
  574. * This function is no longer recommended. Please use
  575. * CFDateFormatterCreateStringWithDate instead.
  576. *
  577. * Availability:
  578. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  579. * CarbonLib: in CarbonLib 1.0 and later
  580. * Non-Carbon CFM: not available
  581. }
  582. procedure DateString( dateTime: SInt32; longFlag: DateForm; var result: Str255; intlHandle: Handle ); external name '_DateString';
  583. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  584. {
  585. * TimeString() *** DEPRECATED ***
  586. *
  587. * Deprecated:
  588. * use CFDateFormatterCreateStringWithDate instead
  589. *
  590. * Discussion:
  591. * This function is no longer recommended. Please use
  592. * CFDateFormatterCreateStringWithDate instead.
  593. *
  594. * Availability:
  595. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  596. * CarbonLib: in CarbonLib 1.0 and later
  597. * Non-Carbon CFM: not available
  598. }
  599. procedure TimeString( dateTime: SInt32; wantSeconds: Boolean; var result: Str255; intlHandle: Handle ); external name '_TimeString';
  600. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  601. {
  602. * LongDateString() *** DEPRECATED ***
  603. *
  604. * Deprecated:
  605. * use CFDateFormatterCreateStringWithDate instead
  606. *
  607. * Discussion:
  608. * This function is no longer recommended. Please use
  609. * CFDateFormatterCreateStringWithDate instead.
  610. *
  611. * Availability:
  612. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  613. * CarbonLib: in CarbonLib 1.0 and later
  614. * Non-Carbon CFM: not available
  615. }
  616. procedure LongDateString( (*const*) var dateTime: LongDateTime; longFlag: DateForm; var result: Str255; intlHandle: Handle ); external name '_LongDateString';
  617. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  618. {
  619. * LongTimeString() *** DEPRECATED ***
  620. *
  621. * Deprecated:
  622. * use CFDateFormatterCreateStringWithDate instead
  623. *
  624. * Discussion:
  625. * This function is no longer recommended. Please use
  626. * CFDateFormatterCreateStringWithDate instead.
  627. *
  628. * Availability:
  629. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  630. * CarbonLib: in CarbonLib 1.0 and later
  631. * Non-Carbon CFM: not available
  632. }
  633. procedure LongTimeString( (*const*) var dateTime: LongDateTime; wantSeconds: Boolean; var result: Str255; intlHandle: Handle ); external name '_LongTimeString';
  634. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  635. {
  636. These routine are available in Carbon and InterfaceLib with their new name
  637. }
  638. {
  639. * InitDateCache() *** DEPRECATED ***
  640. *
  641. * Deprecated:
  642. * No longer needed on MacOS X.
  643. *
  644. * Discussion:
  645. * This function is obsolate.
  646. *
  647. * Availability:
  648. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  649. * CarbonLib: in CarbonLib 1.0 and later
  650. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  651. }
  652. function InitDateCache( theCache: DateCachePtr ): OSErr; external name '_InitDateCache';
  653. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  654. {
  655. * StringToDate() *** DEPRECATED ***
  656. *
  657. * Deprecated:
  658. * use CFDateFormatterCreateDateFromString instead
  659. *
  660. * Discussion:
  661. * This function is no longer recommended. Please use
  662. * CFDateFormatterCreateDateFromString instead.
  663. *
  664. * Availability:
  665. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  666. * CarbonLib: in CarbonLib 1.0 and later
  667. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  668. }
  669. function StringToDate( textPtr: Ptr; textLen: SInt32; theCache: DateCachePtr; var lengthUsed: SInt32; var dateTime: LongDateRec ): StringToDateStatus; external name '_StringToDate';
  670. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  671. {
  672. * StringToTime() *** DEPRECATED ***
  673. *
  674. * Deprecated:
  675. * use CFDateFormatterCreateDateFromString instead
  676. *
  677. * Discussion:
  678. * This function is no longer recommended. Please use
  679. * CFDateFormatterCreateDateFromString instead.
  680. *
  681. * Availability:
  682. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  683. * CarbonLib: in CarbonLib 1.0 and later
  684. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  685. }
  686. function StringToTime( textPtr: Ptr; textLen: SInt32; theCache: DateCachePtr; var lengthUsed: SInt32; var dateTime: LongDateRec ): StringToDateStatus; external name '_StringToTime';
  687. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  688. {
  689. * LongDateToSeconds() *** DEPRECATED ***
  690. *
  691. * Deprecated:
  692. * use CFCalendar instead.
  693. *
  694. * Discussion:
  695. * This function is no longer recommended. Please use CFCalendar
  696. * instead.
  697. *
  698. * Availability:
  699. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  700. * CarbonLib: in CarbonLib 1.0 and later
  701. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  702. }
  703. procedure LongDateToSeconds( const (*var*) lDate: LongDateRec; var lSecs: LongDateTime ); external name '_LongDateToSeconds';
  704. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  705. {
  706. * LongSecondsToDate() *** DEPRECATED ***
  707. *
  708. * Deprecated:
  709. * use CFCalendar instead.
  710. *
  711. * Discussion:
  712. * This function is no longer recommended. Please use CFCalendar
  713. * instead.
  714. *
  715. * Availability:
  716. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  717. * CarbonLib: in CarbonLib 1.0 and later
  718. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  719. }
  720. procedure LongSecondsToDate( (*const*) var lSecs: LongDateTime; var lDate: LongDateRec ); external name '_LongSecondsToDate';
  721. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  722. {
  723. * ToggleDate() *** DEPRECATED ***
  724. *
  725. * Deprecated:
  726. * use CFCalendar instead.
  727. *
  728. * Discussion:
  729. * This function is no longer recommended. Please use CFCalendar
  730. * instead.
  731. *
  732. * Availability:
  733. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  734. * CarbonLib: in CarbonLib 1.0 and later
  735. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  736. }
  737. function ToggleDate( var lSecs: LongDateTime; field: LongDateField; delta: DateDelta; ch: SInt16; const (*var*) params: TogglePB ): ToggleResults; external name '_ToggleDate';
  738. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  739. {
  740. * ValidDate() *** DEPRECATED ***
  741. *
  742. * Deprecated:
  743. * use CFCalendar instead.
  744. *
  745. * Discussion:
  746. * This function is no longer recommended. Please use CFCalendar
  747. * instead.
  748. *
  749. * Availability:
  750. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  751. * CarbonLib: in CarbonLib 1.0 and later
  752. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  753. }
  754. function ValidDate( const (*var*) vDate: LongDateRec; flags: SIGNEDLONG; var newSecs: LongDateTime ): SInt16; external name '_ValidDate';
  755. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  756. {
  757. * ReadDateTime() *** DEPRECATED ***
  758. *
  759. * Deprecated:
  760. * use CFAbsoluteTimeGetCurrent instead.
  761. *
  762. * Discussion:
  763. * This function is no longer recommended. Please use
  764. * CFAbsoluteTimeGetCurrent instead.
  765. *
  766. * Availability:
  767. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  768. * CarbonLib: in CarbonLib 1.0 and later
  769. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  770. }
  771. function ReadDateTime( var datetime: UNSIGNEDLONG ): OSErr; external name '_ReadDateTime';
  772. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  773. {
  774. * GetDateTime() *** DEPRECATED ***
  775. *
  776. * Deprecated:
  777. * use CFAbsoluteTimeGetCurrent instead.
  778. *
  779. * Discussion:
  780. * This function is no longer recommended. Please use
  781. * CFAbsoluteTimeGetCurrent instead.
  782. *
  783. * Availability:
  784. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  785. * CarbonLib: in CarbonLib 1.0 and later
  786. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  787. }
  788. procedure GetDateTime( var secs: UNSIGNEDLONG ); external name '_GetDateTime';
  789. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  790. {
  791. * SetDateTime() *** DEPRECATED ***
  792. *
  793. * Deprecated:
  794. * deprecated it without replacement
  795. *
  796. * Discussion:
  797. * This function is no longer recommended. One has to be root on
  798. * MacOSX to set. This is done through other means on OS X
  799. *
  800. * Availability:
  801. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  802. * CarbonLib: in CarbonLib 1.0 and later
  803. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  804. }
  805. function SetDateTime( datetime: UNSIGNEDLONG ): OSErr; external name '_SetDateTime';
  806. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  807. {
  808. * SetTime() *** DEPRECATED ***
  809. *
  810. * Deprecated:
  811. * deprecated it without replacement
  812. *
  813. * Discussion:
  814. * This function is no longer recommended. One has to be root on
  815. * MacOSX to set. This is done through other means on OS X
  816. *
  817. * Availability:
  818. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  819. * CarbonLib: in CarbonLib 1.0 and later
  820. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  821. }
  822. procedure SetTime( const (*var*) d: DateTimeRec ); external name '_SetTime';
  823. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  824. {
  825. * GetTime() *** DEPRECATED ***
  826. *
  827. * Deprecated:
  828. * use CFAbsoluteTimeGetCurrent instead.
  829. *
  830. * Discussion:
  831. * This function is no longer recommended. Please use
  832. * CFAbsoluteTimeGetCurrent instead.
  833. *
  834. * Availability:
  835. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  836. * CarbonLib: in CarbonLib 1.0 and later
  837. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  838. }
  839. procedure GetTime( var d: DateTimeRec ); external name '_GetTime';
  840. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  841. {$endc} {not TARGET_CPU_64}
  842. {$ifc not TARGET_CPU_64}
  843. {
  844. * DateToSeconds() *** DEPRECATED ***
  845. *
  846. * Deprecated:
  847. * use CFCalendar instead.
  848. *
  849. * Discussion:
  850. * This function is no longer recommended. Please use CFCalendar
  851. * instead.
  852. *
  853. * Availability:
  854. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  855. * CarbonLib: in CarbonLib 1.0 and later
  856. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  857. }
  858. procedure DateToSeconds( const (*var*) d: DateTimeRec; var secs: UNSIGNEDLONG ); external name '_DateToSeconds';
  859. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  860. {$endc} {not TARGET_CPU_64}
  861. {$ifc not TARGET_CPU_64}
  862. {
  863. * SecondsToDate() *** DEPRECATED ***
  864. *
  865. * Deprecated:
  866. * use CFCalendar instead.
  867. *
  868. * Discussion:
  869. * This function is no longer recommended. Please use CFCalendar
  870. * instead.
  871. *
  872. * Availability:
  873. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  874. * CarbonLib: in CarbonLib 1.0 and later
  875. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  876. }
  877. procedure SecondsToDate( secs: UNSIGNEDLONG; var d: DateTimeRec ); external name '_SecondsToDate';
  878. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  879. {
  880. These routine are available in InterfaceLib using their old name.
  881. Macros allow using the new names in all source code.
  882. @deprecated use CFDateFormatter instead.
  883. }
  884. {
  885. * IUDateString() *** DEPRECATED ***
  886. *
  887. * Availability:
  888. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  889. * CarbonLib: not available
  890. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  891. }
  892. {
  893. * IUTimeString() *** DEPRECATED ***
  894. *
  895. * Availability:
  896. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  897. * CarbonLib: not available
  898. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  899. }
  900. {
  901. * IUDatePString() *** DEPRECATED ***
  902. *
  903. * Availability:
  904. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  905. * CarbonLib: not available
  906. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  907. }
  908. {
  909. * IUTimePString() *** DEPRECATED ***
  910. *
  911. * Availability:
  912. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  913. * CarbonLib: not available
  914. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  915. }
  916. {
  917. * IULDateString() *** DEPRECATED ***
  918. *
  919. * Availability:
  920. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  921. * CarbonLib: not available
  922. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  923. }
  924. {
  925. * IULTimeString() *** DEPRECATED ***
  926. *
  927. * Availability:
  928. * Mac OS X: not available [32-bit only] but deprecated in 10.3
  929. * CarbonLib: not available
  930. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  931. }
  932. {$endc} {not TARGET_CPU_64}
  933. {
  934. * iudatestring()
  935. *
  936. * Availability:
  937. * Mac OS X: not available
  938. * CarbonLib: not available
  939. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  940. }
  941. {
  942. * iudatepstring()
  943. *
  944. * Availability:
  945. * Mac OS X: not available
  946. * CarbonLib: not available
  947. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  948. }
  949. {
  950. * iutimestring()
  951. *
  952. * Availability:
  953. * Mac OS X: not available
  954. * CarbonLib: not available
  955. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  956. }
  957. {
  958. * iutimepstring()
  959. *
  960. * Availability:
  961. * Mac OS X: not available
  962. * CarbonLib: not available
  963. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  964. }
  965. {
  966. * iuldatestring()
  967. *
  968. * Availability:
  969. * Mac OS X: not available
  970. * CarbonLib: not available
  971. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  972. }
  973. {
  974. * iultimestring()
  975. *
  976. * Availability:
  977. * Mac OS X: not available
  978. * CarbonLib: not available
  979. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  980. }
  981. {$endc} {not TARGET_CPU_64}
  982. {$endc} {TARGET_OS_MAC}
  983. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  984. end.
  985. {$endc} {not MACOSALLINCLUDE}