/packages/univint/src/CFCalendar.pas

https://github.com/slibre/freepascal · Pascal · 283 lines · 47 code · 46 blank · 190 comment · 0 complexity · 06dac3f034f7d65b753d597f004ba8eb MD5 · raw file

  1. { CFCalendar.h
  2. Copyright (c) 2004-2012, Apple Inc. All rights reserved.
  3. }
  4. { Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, August 2005 }
  5. { Pascal Translation Updated: Gorazd Krosl, <gorazd_1957@yahoo.ca>, October 2009 }
  6. { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2009 }
  7. { Pascal Translation Updated: Jonas Maebe <jonas@freepascal.org>, September 2012 }
  8. {
  9. Modified for use with Free Pascal
  10. Version 308
  11. Please report any bugs to <gpc@microbizz.nl>
  12. }
  13. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$calling mwpascal}
  19. unit CFCalendar;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  22. {$setc GAP_INTERFACES_VERSION := $0308}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  38. {$setc __ppc64__ := 1}
  39. {$elsec}
  40. {$setc __ppc64__ := 0}
  41. {$endc}
  42. {$ifc not defined __i386__ and defined CPUI386}
  43. {$setc __i386__ := 1}
  44. {$elsec}
  45. {$setc __i386__ := 0}
  46. {$endc}
  47. {$ifc not defined __x86_64__ and defined CPUX86_64}
  48. {$setc __x86_64__ := 1}
  49. {$elsec}
  50. {$setc __x86_64__ := 0}
  51. {$endc}
  52. {$ifc not defined __arm__ and defined CPUARM}
  53. {$setc __arm__ := 1}
  54. {$elsec}
  55. {$setc __arm__ := 0}
  56. {$endc}
  57. {$ifc defined cpu64}
  58. {$setc __LP64__ := 1}
  59. {$elsec}
  60. {$setc __LP64__ := 0}
  61. {$endc}
  62. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  63. {$error Conflicting definitions for __ppc__ and __i386__}
  64. {$endc}
  65. {$ifc defined __ppc__ and __ppc__}
  66. {$setc TARGET_CPU_PPC := TRUE}
  67. {$setc TARGET_CPU_PPC64 := FALSE}
  68. {$setc TARGET_CPU_X86 := FALSE}
  69. {$setc TARGET_CPU_X86_64 := FALSE}
  70. {$setc TARGET_CPU_ARM := FALSE}
  71. {$setc TARGET_OS_MAC := TRUE}
  72. {$setc TARGET_OS_IPHONE := FALSE}
  73. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  74. {$setc TARGET_OS_EMBEDDED := FALSE}
  75. {$elifc defined __ppc64__ and __ppc64__}
  76. {$setc TARGET_CPU_PPC := FALSE}
  77. {$setc TARGET_CPU_PPC64 := TRUE}
  78. {$setc TARGET_CPU_X86 := FALSE}
  79. {$setc TARGET_CPU_X86_64 := FALSE}
  80. {$setc TARGET_CPU_ARM := 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 __i386__ and __i386__}
  86. {$setc TARGET_CPU_PPC := FALSE}
  87. {$setc TARGET_CPU_PPC64 := FALSE}
  88. {$setc TARGET_CPU_X86 := TRUE}
  89. {$setc TARGET_CPU_X86_64 := FALSE}
  90. {$setc TARGET_CPU_ARM := FALSE}
  91. {$ifc defined(iphonesim)}
  92. {$setc TARGET_OS_MAC := FALSE}
  93. {$setc TARGET_OS_IPHONE := TRUE}
  94. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  95. {$elsec}
  96. {$setc TARGET_OS_MAC := TRUE}
  97. {$setc TARGET_OS_IPHONE := FALSE}
  98. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  99. {$endc}
  100. {$setc TARGET_OS_EMBEDDED := FALSE}
  101. {$elifc defined __x86_64__ and __x86_64__}
  102. {$setc TARGET_CPU_PPC := FALSE}
  103. {$setc TARGET_CPU_PPC64 := FALSE}
  104. {$setc TARGET_CPU_X86 := FALSE}
  105. {$setc TARGET_CPU_X86_64 := TRUE}
  106. {$setc TARGET_CPU_ARM := FALSE}
  107. {$setc TARGET_OS_MAC := TRUE}
  108. {$setc TARGET_OS_IPHONE := FALSE}
  109. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  110. {$setc TARGET_OS_EMBEDDED := FALSE}
  111. {$elifc defined __arm__ and __arm__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := FALSE}
  115. {$setc TARGET_CPU_X86_64 := FALSE}
  116. {$setc TARGET_CPU_ARM := TRUE}
  117. { will require compiler define when/if other Apple devices with ARM cpus ship }
  118. {$setc TARGET_OS_MAC := FALSE}
  119. {$setc TARGET_OS_IPHONE := TRUE}
  120. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  121. {$setc TARGET_OS_EMBEDDED := TRUE}
  122. {$elsec}
  123. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  124. {$endc}
  125. {$ifc defined __LP64__ and __LP64__ }
  126. {$setc TARGET_CPU_64 := TRUE}
  127. {$elsec}
  128. {$setc TARGET_CPU_64 := FALSE}
  129. {$endc}
  130. {$ifc defined FPC_BIG_ENDIAN}
  131. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  132. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  133. {$elifc defined FPC_LITTLE_ENDIAN}
  134. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  135. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  136. {$elsec}
  137. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  138. {$endc}
  139. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  140. {$setc CALL_NOT_IN_CARBON := FALSE}
  141. {$setc OLDROUTINENAMES := FALSE}
  142. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  143. {$setc OPAQUE_UPP_TYPES := TRUE}
  144. {$setc OTCARBONAPPLICATION := TRUE}
  145. {$setc OTKERNEL := FALSE}
  146. {$setc PM_USE_SESSION_APIS := TRUE}
  147. {$setc TARGET_API_MAC_CARBON := TRUE}
  148. {$setc TARGET_API_MAC_OS8 := FALSE}
  149. {$setc TARGET_API_MAC_OSX := TRUE}
  150. {$setc TARGET_CARBON := TRUE}
  151. {$setc TARGET_CPU_68K := FALSE}
  152. {$setc TARGET_CPU_MIPS := FALSE}
  153. {$setc TARGET_CPU_SPARC := FALSE}
  154. {$setc TARGET_OS_UNIX := FALSE}
  155. {$setc TARGET_OS_WIN32 := FALSE}
  156. {$setc TARGET_RT_MAC_68881 := FALSE}
  157. {$setc TARGET_RT_MAC_CFM := FALSE}
  158. {$setc TARGET_RT_MAC_MACHO := TRUE}
  159. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  160. {$setc TYPE_BOOL := FALSE}
  161. {$setc TYPE_EXTENDED := FALSE}
  162. {$setc TYPE_LONGLONG := TRUE}
  163. uses MacTypes,CFBase,CFLocale,CFDate,CFTimeZone;
  164. {$endc} {not MACOSALLINCLUDE}
  165. {$ALIGN POWER}
  166. {#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
  167. type
  168. CFCalendarRef = ^__CFCalendar; { an opaque type }
  169. __CFCalendar = record end;
  170. function CFCalendarGetTypeID: CFTypeID; external name '_CFCalendarGetTypeID';
  171. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  172. function CFCalendarCopyCurrent: CFCalendarRef; external name '_CFCalendarCopyCurrent';
  173. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  174. function CFCalendarCreateWithIdentifier( allocator: CFAllocatorRef; identifier: CFStringRef ): CFCalendarRef; external name '_CFCalendarCreateWithIdentifier';
  175. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  176. // Create a calendar. The identifiers are the kCF*Calendar
  177. // constants in CFLocale.h.
  178. function CFCalendarGetIdentifier( calendar: CFCalendarRef ): CFStringRef; external name '_CFCalendarGetIdentifier';
  179. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  180. // Returns the calendar's identifier.
  181. function CFCalendarCopyLocale( calendar: CFCalendarRef ): CFLocaleRef; external name '_CFCalendarCopyLocale';
  182. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  183. procedure CFCalendarSetLocale( calendar: CFCalendarRef; locale: CFLocaleRef ); external name '_CFCalendarSetLocale';
  184. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  185. function CFCalendarCopyTimeZone( calendar: CFCalendarRef ): CFTimeZoneRef; external name '_CFCalendarCopyTimeZone';
  186. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  187. procedure CFCalendarSetTimeZone( calendar: CFCalendarRef; tz: CFTimeZoneRef ); external name '_CFCalendarSetTimeZone';
  188. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  189. function CFCalendarGetFirstWeekday( calendar: CFCalendarRef ): CFIndex; external name '_CFCalendarGetFirstWeekday';
  190. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  191. procedure CFCalendarSetFirstWeekday( calendar: CFCalendarRef; wkdy: CFIndex ); external name '_CFCalendarSetFirstWeekday';
  192. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  193. function CFCalendarGetMinimumDaysInFirstWeek( calendar: CFCalendarRef ): CFIndex; external name '_CFCalendarGetMinimumDaysInFirstWeek';
  194. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  195. procedure CFCalendarSetMinimumDaysInFirstWeek( calendar: CFCalendarRef; mwd: CFIndex ); external name '_CFCalendarSetMinimumDaysInFirstWeek';
  196. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  197. type
  198. CFCalendarUnit = UNSIGNEDLONG;
  199. const
  200. kCFCalendarUnitEra = 1 shl 1;
  201. kCFCalendarUnitYear = 1 shl 2;
  202. kCFCalendarUnitMonth = 1 shl 3;
  203. kCFCalendarUnitDay = 1 shl 4;
  204. kCFCalendarUnitHour = 1 shl 5;
  205. kCFCalendarUnitMinute = 1 shl 6;
  206. kCFCalendarUnitSecond = 1 shl 7;
  207. kCFCalendarUnitWeek = 1 shl 8;
  208. kCFCalendarUnitWeekday = 1 shl 9;
  209. kCFCalendarUnitWeekdayOrdinal = 1 shl 10;
  210. kCFCalendarUnitQuarter = 1 shl 11; { CF_AVAILABLE_STARTING(10_6, 4_0); }
  211. kCFCalendarUnitWeekOfMonth = 1 shl 12; { CF_AVAILABLE_STARTING(10_7, 5_0) }
  212. kCFCalendarUnitWeekOfYear = 1 shl 13; { CF_AVAILABLE_STARTING(10_7, 5_0) }
  213. kCFCalendarUnitYearForWeekOfYear = 1 shl 14; { CF_AVAILABLE_STARTING(10_7, 5_0) }
  214. function CFCalendarGetMinimumRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit ): CFRange; external name '_CFCalendarGetMinimumRangeOfUnit';
  215. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  216. function CFCalendarGetMaximumRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit ): CFRange; external name '_CFCalendarGetMaximumRangeOfUnit';
  217. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  218. function CFCalendarGetRangeOfUnit( calendar: CFCalendarRef; smallerUnit: CFCalendarUnit; biggerUnit: CFCalendarUnit; at: CFAbsoluteTime ): CFRange; external name '_CFCalendarGetRangeOfUnit';
  219. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  220. function CFCalendarGetOrdinalityOfUnit( calendar: CFCalendarRef; smallerUnit: CFCalendarUnit; biggerUnit: CFCalendarUnit; at: CFAbsoluteTime ): CFIndex; external name '_CFCalendarGetOrdinalityOfUnit';
  221. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  222. function CFCalendarGetTimeRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit; at: CFAbsoluteTime; var startp: CFAbsoluteTime; var tip: CFTimeInterval ): Boolean; external name '_CFCalendarGetTimeRangeOfUnit';
  223. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  224. function CFCalendarComposeAbsoluteTime( calendar: CFCalendarRef; var at: { out } CFAbsoluteTime; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarComposeAbsoluteTime';
  225. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  226. function CFCalendarDecomposeAbsoluteTime( calendar: CFCalendarRef; at: CFAbsoluteTime; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarDecomposeAbsoluteTime';
  227. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  228. const
  229. kCFCalendarComponentsWrap = 1 shl 0; // option for adding
  230. function CFCalendarAddComponents( calendar: CFCalendarRef; var at: { inout } CFAbsoluteTime; options: CFOptionFlags; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarAddComponents';
  231. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  232. function CFCalendarGetComponentDifference( calendar: CFCalendarRef; startingAT: CFAbsoluteTime; resultAT: CFAbsoluteTime; options: CFOptionFlags; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarGetComponentDifference';
  233. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  234. {#endif}
  235. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  236. end.
  237. {$endc} {not MACOSALLINCLUDE}