PageRenderTime 55ms CodeModel.GetById 50ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/packages/univint/src/CFDate.pas

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