PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  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
 14{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 15{$mode macpas}
 16{$packenum 1}
 17{$macro on}
 18{$inline on}
 19{$calling mwpascal}
 20
 21unit CFCalendar;
 22interface
 23{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
 24{$setc GAP_INTERFACES_VERSION := $0308}
 25
 26{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 27    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 28{$endc}
 29
 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
 37{$ifc not defined __ppc__ and defined CPUPOWERPC32}
 38	{$setc __ppc__ := 1}
 39{$elsec}
 40	{$setc __ppc__ := 0}
 41{$endc}
 42{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
 43	{$setc __ppc64__ := 1}
 44{$elsec}
 45	{$setc __ppc64__ := 0}
 46{$endc}
 47{$ifc not defined __i386__ and defined CPUI386}
 48	{$setc __i386__ := 1}
 49{$elsec}
 50	{$setc __i386__ := 0}
 51{$endc}
 52{$ifc not defined __x86_64__ and defined CPUX86_64}
 53	{$setc __x86_64__ := 1}
 54{$elsec}
 55	{$setc __x86_64__ := 0}
 56{$endc}
 57{$ifc not defined __arm__ and defined CPUARM}
 58	{$setc __arm__ := 1}
 59{$elsec}
 60	{$setc __arm__ := 0}
 61{$endc}
 62
 63{$ifc defined cpu64}
 64  {$setc __LP64__ := 1}
 65{$elsec}
 66  {$setc __LP64__ := 0}
 67{$endc}
 68
 69
 70{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 71	{$error Conflicting definitions for __ppc__ and __i386__}
 72{$endc}
 73
 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_OS_MAC := TRUE}
 81	{$setc TARGET_OS_IPHONE := FALSE}
 82	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 83	{$setc TARGET_OS_EMBEDDED := FALSE}
 84{$elifc defined __ppc64__ and __ppc64__}
 85	{$setc TARGET_CPU_PPC := FALSE}
 86	{$setc TARGET_CPU_PPC64 := TRUE}
 87	{$setc TARGET_CPU_X86 := FALSE}
 88	{$setc TARGET_CPU_X86_64 := FALSE}
 89	{$setc TARGET_CPU_ARM := FALSE}
 90	{$setc TARGET_OS_MAC := TRUE}
 91	{$setc TARGET_OS_IPHONE := FALSE}
 92	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 93	{$setc TARGET_OS_EMBEDDED := FALSE}
 94{$elifc defined __i386__ and __i386__}
 95	{$setc TARGET_CPU_PPC := FALSE}
 96	{$setc TARGET_CPU_PPC64 := FALSE}
 97	{$setc TARGET_CPU_X86 := TRUE}
 98	{$setc TARGET_CPU_X86_64 := FALSE}
 99	{$setc TARGET_CPU_ARM := FALSE}
100{$ifc defined(iphonesim)}
101 	{$setc TARGET_OS_MAC := FALSE}
102	{$setc TARGET_OS_IPHONE := TRUE}
103	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
104{$elsec}
105	{$setc TARGET_OS_MAC := TRUE}
106	{$setc TARGET_OS_IPHONE := FALSE}
107	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
108{$endc}
109	{$setc TARGET_OS_EMBEDDED := FALSE}
110{$elifc defined __x86_64__ and __x86_64__}
111	{$setc TARGET_CPU_PPC := FALSE}
112	{$setc TARGET_CPU_PPC64 := FALSE}
113	{$setc TARGET_CPU_X86 := FALSE}
114	{$setc TARGET_CPU_X86_64 := TRUE}
115	{$setc TARGET_CPU_ARM := FALSE}
116	{$setc TARGET_OS_MAC := TRUE}
117	{$setc TARGET_OS_IPHONE := FALSE}
118	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
119	{$setc TARGET_OS_EMBEDDED := FALSE}
120{$elifc defined __arm__ and __arm__}
121	{$setc TARGET_CPU_PPC := FALSE}
122	{$setc TARGET_CPU_PPC64 := FALSE}
123	{$setc TARGET_CPU_X86 := FALSE}
124	{$setc TARGET_CPU_X86_64 := FALSE}
125	{$setc TARGET_CPU_ARM := TRUE}
126	{ will require compiler define when/if other Apple devices with ARM cpus ship }
127	{$setc TARGET_OS_MAC := FALSE}
128	{$setc TARGET_OS_IPHONE := TRUE}
129	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
130	{$setc TARGET_OS_EMBEDDED := TRUE}
131{$elsec}
132	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
133{$endc}
134
135{$ifc defined __LP64__ and __LP64__ }
136  {$setc TARGET_CPU_64 := TRUE}
137{$elsec}
138  {$setc TARGET_CPU_64 := FALSE}
139{$endc}
140
141{$ifc defined FPC_BIG_ENDIAN}
142	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
143	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
144{$elifc defined FPC_LITTLE_ENDIAN}
145	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
146	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
147{$elsec}
148	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
149{$endc}
150{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
151{$setc CALL_NOT_IN_CARBON := FALSE}
152{$setc OLDROUTINENAMES := FALSE}
153{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
154{$setc OPAQUE_UPP_TYPES := TRUE}
155{$setc OTCARBONAPPLICATION := TRUE}
156{$setc OTKERNEL := FALSE}
157{$setc PM_USE_SESSION_APIS := TRUE}
158{$setc TARGET_API_MAC_CARBON := TRUE}
159{$setc TARGET_API_MAC_OS8 := FALSE}
160{$setc TARGET_API_MAC_OSX := TRUE}
161{$setc TARGET_CARBON := TRUE}
162{$setc TARGET_CPU_68K := FALSE}
163{$setc TARGET_CPU_MIPS := FALSE}
164{$setc TARGET_CPU_SPARC := FALSE}
165{$setc TARGET_OS_UNIX := FALSE}
166{$setc TARGET_OS_WIN32 := FALSE}
167{$setc TARGET_RT_MAC_68881 := FALSE}
168{$setc TARGET_RT_MAC_CFM := FALSE}
169{$setc TARGET_RT_MAC_MACHO := TRUE}
170{$setc TYPED_FUNCTION_POINTERS := TRUE}
171{$setc TYPE_BOOL := FALSE}
172{$setc TYPE_EXTENDED := FALSE}
173{$setc TYPE_LONGLONG := TRUE}
174uses MacTypes,CFBase,CFLocale,CFDate,CFTimeZone;
175{$endc} {not MACOSALLINCLUDE}
176
177{$ALIGN POWER}
178
179
180{#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
181
182
183type
184	CFCalendarRef = ^__CFCalendar; { an opaque type }
185	__CFCalendar = record end;
186
187function CFCalendarGetTypeID: CFTypeID; external name '_CFCalendarGetTypeID';
188(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
189
190function CFCalendarCopyCurrent: CFCalendarRef; external name '_CFCalendarCopyCurrent';
191(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
192
193function CFCalendarCreateWithIdentifier( allocator: CFAllocatorRef; identifier: CFStringRef ): CFCalendarRef; external name '_CFCalendarCreateWithIdentifier';
194(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
195	// Create a calendar.  The identifiers are the kCF*Calendar
196	// constants in CFLocale.h.
197
198function CFCalendarGetIdentifier( calendar: CFCalendarRef ): CFStringRef; external name '_CFCalendarGetIdentifier';
199(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
200	// Returns the calendar's identifier.
201
202function CFCalendarCopyLocale( calendar: CFCalendarRef ): CFLocaleRef; external name '_CFCalendarCopyLocale';
203(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
204
205procedure CFCalendarSetLocale( calendar: CFCalendarRef; locale: CFLocaleRef ); external name '_CFCalendarSetLocale';
206(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
207
208function CFCalendarCopyTimeZone( calendar: CFCalendarRef ): CFTimeZoneRef; external name '_CFCalendarCopyTimeZone';
209(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
210
211procedure CFCalendarSetTimeZone( calendar: CFCalendarRef; tz: CFTimeZoneRef ); external name '_CFCalendarSetTimeZone';
212(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
213
214function CFCalendarGetFirstWeekday( calendar: CFCalendarRef ): CFIndex; external name '_CFCalendarGetFirstWeekday';
215(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
216
217procedure CFCalendarSetFirstWeekday( calendar: CFCalendarRef; wkdy: CFIndex ); external name '_CFCalendarSetFirstWeekday';
218(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
219
220function CFCalendarGetMinimumDaysInFirstWeek( calendar: CFCalendarRef ): CFIndex; external name '_CFCalendarGetMinimumDaysInFirstWeek';
221(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
222
223procedure CFCalendarSetMinimumDaysInFirstWeek( calendar: CFCalendarRef; mwd: CFIndex ); external name '_CFCalendarSetMinimumDaysInFirstWeek';
224(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
225
226
227type
228	CFCalendarUnit = UNSIGNEDLONG;
229const
230	kCFCalendarUnitEra = 1 shl 1;
231	kCFCalendarUnitYear = 1 shl 2;
232	kCFCalendarUnitMonth = 1 shl 3;
233	kCFCalendarUnitDay = 1 shl 4;
234	kCFCalendarUnitHour = 1 shl 5;
235	kCFCalendarUnitMinute = 1 shl 6;
236	kCFCalendarUnitSecond = 1 shl 7;
237	kCFCalendarUnitWeek = 1 shl 8;
238	kCFCalendarUnitWeekday = 1 shl 9;
239	kCFCalendarUnitWeekdayOrdinal = 1 shl 10;
240	kCFCalendarUnitQuarter = 1 shl 11; { CF_AVAILABLE_STARTING(10_6, 4_0); }
241	kCFCalendarUnitWeekOfMonth = 1 shl 12; { CF_AVAILABLE_STARTING(10_7, 5_0) }
242	kCFCalendarUnitWeekOfYear = 1 shl 13; { CF_AVAILABLE_STARTING(10_7, 5_0) }
243	kCFCalendarUnitYearForWeekOfYear = 1 shl 14; { CF_AVAILABLE_STARTING(10_7, 5_0) }
244
245function CFCalendarGetMinimumRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit ): CFRange; external name '_CFCalendarGetMinimumRangeOfUnit';
246(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
247
248function CFCalendarGetMaximumRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit ): CFRange; external name '_CFCalendarGetMaximumRangeOfUnit';
249(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
250
251function CFCalendarGetRangeOfUnit( calendar: CFCalendarRef; smallerUnit: CFCalendarUnit; biggerUnit: CFCalendarUnit; at: CFAbsoluteTime ): CFRange; external name '_CFCalendarGetRangeOfUnit';
252(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
253
254function CFCalendarGetOrdinalityOfUnit( calendar: CFCalendarRef; smallerUnit: CFCalendarUnit; biggerUnit: CFCalendarUnit; at: CFAbsoluteTime ): CFIndex; external name '_CFCalendarGetOrdinalityOfUnit';
255(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
256
257function CFCalendarGetTimeRangeOfUnit( calendar: CFCalendarRef; unt: CFCalendarUnit; at: CFAbsoluteTime; var startp: CFAbsoluteTime; var tip: CFTimeInterval ): Boolean; external name '_CFCalendarGetTimeRangeOfUnit';
258(* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
259
260function CFCalendarComposeAbsoluteTime( calendar: CFCalendarRef; var at: { out } CFAbsoluteTime; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarComposeAbsoluteTime';
261(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
262
263function CFCalendarDecomposeAbsoluteTime( calendar: CFCalendarRef; at: CFAbsoluteTime; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarDecomposeAbsoluteTime';
264(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
265
266
267const
268	kCFCalendarComponentsWrap = 1 shl 0;  // option for adding
269
270function CFCalendarAddComponents( calendar: CFCalendarRef; var at: { inout } CFAbsoluteTime; options: CFOptionFlags; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarAddComponents';
271(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
272
273function CFCalendarGetComponentDifference( calendar: CFCalendarRef; startingAT: CFAbsoluteTime; resultAT: CFAbsoluteTime; options: CFOptionFlags; componentDesc: ConstCStringPtr; ... ): Boolean; external name '_CFCalendarGetComponentDifference';
274(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
275
276
277
278{#endif}
279
280{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
281
282end.
283{$endc} {not MACOSALLINCLUDE}