CFDate.pas 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. { CFDate.h
  2. Copyright (c) 1998-2012, Apple Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 2005 }
  5. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  6. { Pascal Translation Updated: Jonas Maebe <[email protected]>, September 2012 }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$packenum 1}
  15. {$macro on}
  16. {$inline on}
  17. {$calling mwpascal}
  18. unit CFDate;
  19. interface
  20. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  21. {$setc GAP_INTERFACES_VERSION := $0308}
  22. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  23. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  24. {$endc}
  25. {$ifc defined CPUPOWERPC and defined CPUI386}
  26. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  27. {$endc}
  28. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  29. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  30. {$endc}
  31. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  32. {$setc __ppc__ := 1}
  33. {$elsec}
  34. {$setc __ppc__ := 0}
  35. {$endc}
  36. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  37. {$setc __ppc64__ := 1}
  38. {$elsec}
  39. {$setc __ppc64__ := 0}
  40. {$endc}
  41. {$ifc not defined __i386__ and defined CPUI386}
  42. {$setc __i386__ := 1}
  43. {$elsec}
  44. {$setc __i386__ := 0}
  45. {$endc}
  46. {$ifc not defined __x86_64__ and defined CPUX86_64}
  47. {$setc __x86_64__ := 1}
  48. {$elsec}
  49. {$setc __x86_64__ := 0}
  50. {$endc}
  51. {$ifc not defined __arm__ and defined CPUARM}
  52. {$setc __arm__ := 1}
  53. {$elsec}
  54. {$setc __arm__ := 0}
  55. {$endc}
  56. {$ifc not defined __arm64__ and defined CPUAARCH64}
  57. {$setc __arm64__ := 1}
  58. {$elsec}
  59. {$setc __arm64__ := 0}
  60. {$endc}
  61. {$ifc defined cpu64}
  62. {$setc __LP64__ := 1}
  63. {$elsec}
  64. {$setc __LP64__ := 0}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  67. {$error Conflicting definitions for __ppc__ and __i386__}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__}
  70. {$setc TARGET_CPU_PPC := TRUE}
  71. {$setc TARGET_CPU_PPC64 := FALSE}
  72. {$setc TARGET_CPU_X86 := FALSE}
  73. {$setc TARGET_CPU_X86_64 := FALSE}
  74. {$setc TARGET_CPU_ARM := FALSE}
  75. {$setc TARGET_CPU_ARM64 := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_IPHONE := FALSE}
  78. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  79. {$setc TARGET_OS_EMBEDDED := FALSE}
  80. {$elifc defined __ppc64__ and __ppc64__}
  81. {$setc TARGET_CPU_PPC := FALSE}
  82. {$setc TARGET_CPU_PPC64 := TRUE}
  83. {$setc TARGET_CPU_X86 := FALSE}
  84. {$setc TARGET_CPU_X86_64 := FALSE}
  85. {$setc TARGET_CPU_ARM := FALSE}
  86. {$setc TARGET_CPU_ARM64 := FALSE}
  87. {$setc TARGET_OS_MAC := TRUE}
  88. {$setc TARGET_OS_IPHONE := FALSE}
  89. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  90. {$setc TARGET_OS_EMBEDDED := FALSE}
  91. {$elifc defined __i386__ and __i386__}
  92. {$setc TARGET_CPU_PPC := FALSE}
  93. {$setc TARGET_CPU_PPC64 := FALSE}
  94. {$setc TARGET_CPU_X86 := TRUE}
  95. {$setc TARGET_CPU_X86_64 := FALSE}
  96. {$setc TARGET_CPU_ARM := FALSE}
  97. {$setc TARGET_CPU_ARM64 := FALSE}
  98. {$ifc defined(iphonesim)}
  99. {$setc TARGET_OS_MAC := FALSE}
  100. {$setc TARGET_OS_IPHONE := TRUE}
  101. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  102. {$elsec}
  103. {$setc TARGET_OS_MAC := TRUE}
  104. {$setc TARGET_OS_IPHONE := FALSE}
  105. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  106. {$endc}
  107. {$setc TARGET_OS_EMBEDDED := FALSE}
  108. {$elifc defined __x86_64__ and __x86_64__}
  109. {$setc TARGET_CPU_PPC := FALSE}
  110. {$setc TARGET_CPU_PPC64 := FALSE}
  111. {$setc TARGET_CPU_X86 := FALSE}
  112. {$setc TARGET_CPU_X86_64 := TRUE}
  113. {$setc TARGET_CPU_ARM := FALSE}
  114. {$setc TARGET_CPU_ARM64 := FALSE}
  115. {$ifc defined(iphonesim)}
  116. {$setc TARGET_OS_MAC := FALSE}
  117. {$setc TARGET_OS_IPHONE := TRUE}
  118. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  119. {$elsec}
  120. {$setc TARGET_OS_MAC := TRUE}
  121. {$setc TARGET_OS_IPHONE := FALSE}
  122. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  123. {$endc}
  124. {$setc TARGET_OS_EMBEDDED := FALSE}
  125. {$elifc defined __arm__ and __arm__}
  126. {$setc TARGET_CPU_PPC := FALSE}
  127. {$setc TARGET_CPU_PPC64 := FALSE}
  128. {$setc TARGET_CPU_X86 := FALSE}
  129. {$setc TARGET_CPU_X86_64 := FALSE}
  130. {$setc TARGET_CPU_ARM := TRUE}
  131. {$setc TARGET_CPU_ARM64 := FALSE}
  132. { will require compiler define when/if other Apple devices with ARM cpus ship }
  133. {$setc TARGET_OS_MAC := FALSE}
  134. {$setc TARGET_OS_IPHONE := TRUE}
  135. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  136. {$setc TARGET_OS_EMBEDDED := TRUE}
  137. {$elifc defined __arm64__ and __arm64__}
  138. {$setc TARGET_CPU_PPC := FALSE}
  139. {$setc TARGET_CPU_PPC64 := FALSE}
  140. {$setc TARGET_CPU_X86 := FALSE}
  141. {$setc TARGET_CPU_X86_64 := FALSE}
  142. {$setc TARGET_CPU_ARM := FALSE}
  143. {$setc TARGET_CPU_ARM64 := TRUE}
  144. { will require compiler define when/if other Apple devices with ARM cpus ship }
  145. {$setc TARGET_OS_MAC := FALSE}
  146. {$setc TARGET_OS_IPHONE := TRUE}
  147. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  148. {$setc TARGET_OS_EMBEDDED := TRUE}
  149. {$elsec}
  150. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  151. {$endc}
  152. {$ifc defined __LP64__ and __LP64__ }
  153. {$setc TARGET_CPU_64 := TRUE}
  154. {$elsec}
  155. {$setc TARGET_CPU_64 := FALSE}
  156. {$endc}
  157. {$ifc defined FPC_BIG_ENDIAN}
  158. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  159. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  160. {$elifc defined FPC_LITTLE_ENDIAN}
  161. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  162. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  163. {$elsec}
  164. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  165. {$endc}
  166. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  167. {$setc CALL_NOT_IN_CARBON := FALSE}
  168. {$setc OLDROUTINENAMES := FALSE}
  169. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  170. {$setc OPAQUE_UPP_TYPES := TRUE}
  171. {$setc OTCARBONAPPLICATION := TRUE}
  172. {$setc OTKERNEL := FALSE}
  173. {$setc PM_USE_SESSION_APIS := TRUE}
  174. {$setc TARGET_API_MAC_CARBON := TRUE}
  175. {$setc TARGET_API_MAC_OS8 := FALSE}
  176. {$setc TARGET_API_MAC_OSX := TRUE}
  177. {$setc TARGET_CARBON := TRUE}
  178. {$setc TARGET_CPU_68K := FALSE}
  179. {$setc TARGET_CPU_MIPS := FALSE}
  180. {$setc TARGET_CPU_SPARC := FALSE}
  181. {$setc TARGET_OS_UNIX := FALSE}
  182. {$setc TARGET_OS_WIN32 := FALSE}
  183. {$setc TARGET_RT_MAC_68881 := FALSE}
  184. {$setc TARGET_RT_MAC_CFM := FALSE}
  185. {$setc TARGET_RT_MAC_MACHO := TRUE}
  186. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  187. {$setc TYPE_BOOL := FALSE}
  188. {$setc TYPE_EXTENDED := FALSE}
  189. {$setc TYPE_LONGLONG := TRUE}
  190. uses MacTypes,CFBase;
  191. {$endc} {not MACOSALLINCLUDE}
  192. {$ALIGN POWER}
  193. type
  194. CFTimeInterval = Float64;
  195. CFAbsoluteTime = CFTimeInterval;
  196. CFAbsoluteTimePtr = ^CFAbsoluteTime;
  197. { absolute time is the time interval since the reference date }
  198. { the reference date (epoch) is 00:00:00 1 January 2001. }
  199. function CFAbsoluteTimeGetCurrent: CFAbsoluteTime; external name '_CFAbsoluteTimeGetCurrent';
  200. var kCFAbsoluteTimeIntervalSince1970: CFTimeInterval; external name '_kCFAbsoluteTimeIntervalSince1970'; (* attribute const *)
  201. var kCFAbsoluteTimeIntervalSince1904: CFTimeInterval; external name '_kCFAbsoluteTimeIntervalSince1904'; (* attribute const *)
  202. type
  203. CFDateRef = ^__CFDate; { an opaque type }
  204. __CFDate = record end;
  205. CFDateRefPtr = ^CFDateRef;
  206. function CFDateGetTypeID: CFTypeID; external name '_CFDateGetTypeID';
  207. function CFDateCreate( allocator: CFAllocatorRef; at: CFAbsoluteTime ): CFDateRef; external name '_CFDateCreate';
  208. function CFDateGetAbsoluteTime( theDate: CFDateRef ): CFAbsoluteTime; external name '_CFDateGetAbsoluteTime';
  209. function CFDateGetTimeIntervalSinceDate( theDate: CFDateRef; otherDate: CFDateRef ): CFTimeInterval; external name '_CFDateGetTimeIntervalSinceDate';
  210. function CFDateCompare( theDate: CFDateRef; otherDate: CFDateRef; context: UnivPtr ): CFComparisonResult; external name '_CFDateCompare';
  211. type
  212. CFTimeZoneRef = ^__CFTimeZone; { an opaque type }
  213. __CFTimeZone = record end;
  214. CFTimeZoneRefPtr = ^CFTimeZoneRef;
  215. type
  216. CFGregorianDate = record
  217. year: SInt32;
  218. month: SInt8;
  219. day: SInt8;
  220. hour: SInt8;
  221. minute: SInt8;
  222. second: Float64;
  223. end;
  224. CFGregorianDatePtr = ^CFGregorianDate;
  225. type
  226. CFGregorianUnits = record
  227. years: SInt32;
  228. months: SInt32;
  229. days: SInt32;
  230. hours: SInt32;
  231. minutes: SInt32;
  232. seconds: Float64;
  233. end;
  234. CFGregorianUnitsPtr = ^CFGregorianUnits;
  235. type
  236. CFGregorianUnitFlags = CFOptionFlags;
  237. const
  238. kCFGregorianUnitsYears = 1 shl 0;
  239. kCFGregorianUnitsMonths = 1 shl 1;
  240. kCFGregorianUnitsDays = 1 shl 2;
  241. kCFGregorianUnitsHours = 1 shl 3;
  242. kCFGregorianUnitsMinutes = 1 shl 4;
  243. kCFGregorianUnitsSeconds = 1 shl 5;
  244. kCFGregorianAllUnits = $00FFFFFF;
  245. function CFGregorianDateIsValid( gdate: CFGregorianDate; unitFlags: CFOptionFlags ): Boolean; external name '_CFGregorianDateIsValid';
  246. function CFGregorianDateGetAbsoluteTime( gdate: CFGregorianDate; tz: CFTimeZoneRef ): CFAbsoluteTime; external name '_CFGregorianDateGetAbsoluteTime';
  247. function CFAbsoluteTimeGetGregorianDate( at: CFAbsoluteTime; tz: CFTimeZoneRef ): CFGregorianDate; external name '_CFAbsoluteTimeGetGregorianDate';
  248. function CFAbsoluteTimeAddGregorianUnits( at: CFAbsoluteTime; tz: CFTimeZoneRef; units: CFGregorianUnits ): CFAbsoluteTime; external name '_CFAbsoluteTimeAddGregorianUnits';
  249. function CFAbsoluteTimeGetDifferenceAsGregorianUnits( at1: CFAbsoluteTime; at2: CFAbsoluteTime; tz: CFTimeZoneRef; unitFlags: CFOptionFlags ): CFGregorianUnits; external name '_CFAbsoluteTimeGetDifferenceAsGregorianUnits';
  250. function CFAbsoluteTimeGetDayOfWeek( at: CFAbsoluteTime; tz: CFTimeZoneRef ): SInt32; external name '_CFAbsoluteTimeGetDayOfWeek';
  251. function CFAbsoluteTimeGetDayOfYear( at: CFAbsoluteTime; tz: CFTimeZoneRef ): SInt32; external name '_CFAbsoluteTimeGetDayOfYear';
  252. function CFAbsoluteTimeGetWeekOfYear( at: CFAbsoluteTime; tz: CFTimeZoneRef ): SInt32; external name '_CFAbsoluteTimeGetWeekOfYear';
  253. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  254. end.
  255. {$endc} {not MACOSALLINCLUDE}