CFDateFormatter.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. { CFDateFormatter.h
  2. Copyright (c) 2003-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CFDateFormatter;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CFBase,CFDate,CFLocale;
  87. {$ALIGN POWER}
  88. {#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
  89. type
  90. CFDateFormatterRef = ^SInt32; { an opaque 32-bit type }
  91. // CFDateFormatters are not thread-safe. Do not use one from multiple threads!
  92. function CFDateFormatterGetTypeID: CFTypeID; external name '_CFDateFormatterGetTypeID';
  93. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  94. // date and time format styles
  95. type
  96. CFDateFormatterStyle = SInt32;
  97. const
  98. kCFDateFormatterNoStyle = 0;
  99. kCFDateFormatterShortStyle = 1;
  100. kCFDateFormatterMediumStyle = 2;
  101. kCFDateFormatterLongStyle = 3;
  102. kCFDateFormatterFullStyle = 4;
  103. // The exact formatted result for these date and time styles depends on the
  104. // locale, but generally:
  105. // Short is completely numeric, such as "12/13/52" or "3:30pm"
  106. // Medium is longer, such as "Jan 12, 1952"
  107. // Long is longer, such as "January 12, 1952" or "3:30:32pm"
  108. // Full is pretty complete; e.g. "Tuesday, April 12, 1952 AD" or "3:30:42pm PST"
  109. // The specifications though are left fuzzy, in part simply because a user's
  110. // preference choices may affect the output, and also the results may change
  111. // from one OS release to another. To produce an exactly formatted date you
  112. // should not rely on styles and localization, but set the format string and
  113. // use nothing but numbers.
  114. function CFDateFormatterCreate( allocator: CFAllocatorRef; locale: CFLocaleRef; dateStyle: CFDateFormatterStyle; timeStyle: CFDateFormatterStyle ): CFDateFormatterRef; external name '_CFDateFormatterCreate';
  115. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  116. // Returns a CFDateFormatter, localized to the given locale, which
  117. // will format dates to the given date and time styles.
  118. function CFDateFormatterGetLocale( formatter: CFDateFormatterRef ): CFLocaleRef; external name '_CFDateFormatterGetLocale';
  119. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  120. function CFDateFormatterGetDateStyle( formatter: CFDateFormatterRef ): CFDateFormatterStyle; external name '_CFDateFormatterGetDateStyle';
  121. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  122. function CFDateFormatterGetTimeStyle( formatter: CFDateFormatterRef ): CFDateFormatterStyle; external name '_CFDateFormatterGetTimeStyle';
  123. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  124. // Get the properties with which the date formatter was created.
  125. function CFDateFormatterGetFormat( formatter: CFDateFormatterRef ): CFStringRef; external name '_CFDateFormatterGetFormat';
  126. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  127. procedure CFDateFormatterSetFormat( formatter: CFDateFormatterRef; formatString: CFStringRef ); external name '_CFDateFormatterSetFormat';
  128. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  129. // Set the format description string of the date formatter. This
  130. // overrides the style settings. The format of the format string
  131. // is as defined by the ICU library. The date formatter starts with a
  132. // default format string defined by the style arguments with
  133. // which it was created.
  134. function CFDateFormatterCreateStringWithDate( allocator: CFAllocatorRef; formatter: CFDateFormatterRef; date: CFDateRef ): CFStringRef; external name '_CFDateFormatterCreateStringWithDate';
  135. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  136. function CFDateFormatterCreateStringWithAbsoluteTime( allocator: CFAllocatorRef; formatter: CFDateFormatterRef; at: CFAbsoluteTime ): CFStringRef; external name '_CFDateFormatterCreateStringWithAbsoluteTime';
  137. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  138. // Create a string representation of the given date or CFAbsoluteTime
  139. // using the current state of the date formatter.
  140. function CFDateFormatterCreateDateFromString( allocator: CFAllocatorRef; formatter: CFDateFormatterRef; strng: CFStringRef; rangep: CFRangePtr ): CFDateRef; external name '_CFDateFormatterCreateDateFromString';
  141. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  142. function CFDateFormatterGetAbsoluteTimeFromString( formatter: CFDateFormatterRef; strng: CFStringRef; rangep: CFRangePtr; atp: CFAbsoluteTimePtr ): Boolean; external name '_CFDateFormatterGetAbsoluteTimeFromString';
  143. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  144. // Parse a string representation of a date using the current state
  145. // of the date formatter. The range parameter specifies the range
  146. // of the string in which the parsing should occur in input, and on
  147. // output indicates the extent that was used; this parameter can
  148. // be NULL, in which case the whole string may be used. The
  149. // return value indicates whether some date was computed and
  150. // (if atp is not NULL) stored at the location specified by atp.
  151. procedure CFDateFormatterSetProperty( formatter: CFDateFormatterRef; key: CFStringRef; value: CFTypeRef ); external name '_CFDateFormatterSetProperty';
  152. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  153. function CFDateFormatterCopyProperty( formatter: CFDateFormatterRef; key: CFStringRef ): CFTypeRef; external name '_CFDateFormatterCopyProperty';
  154. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  155. // Set and get various properties of the date formatter, the set of
  156. // which may be expanded in the future.
  157. var kCFDateFormatterIsLenient: CFStringRef; external name '_kCFDateFormatterIsLenient'; (* attribute const *)
  158. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // CFBoolean
  159. var kCFDateFormatterTimeZone: CFStringRef; external name '_kCFDateFormatterTimeZone'; (* attribute const *)
  160. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // CFTimeZone
  161. var kCFDateFormatterCalendarName: CFStringRef; external name '_kCFDateFormatterCalendarName'; (* attribute const *)
  162. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // CFString
  163. var kCFDateFormatterDefaultFormat: CFStringRef; external name '_kCFDateFormatterDefaultFormat'; (* attribute const *)
  164. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // CFString
  165. var kCFDateFormatterTwoDigitStartDate: CFStringRef; external name '_kCFDateFormatterTwoDigitStartDate'; (* attribute const *)
  166. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFDate
  167. var kCFDateFormatterDefaultDate: CFStringRef; external name '_kCFDateFormatterDefaultDate'; (* attribute const *)
  168. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFDate
  169. var kCFDateFormatterCalendar: CFStringRef; external name '_kCFDateFormatterCalendar'; (* attribute const *)
  170. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFCalendar
  171. var kCFDateFormatterEraSymbols: CFStringRef; external name '_kCFDateFormatterEraSymbols'; (* attribute const *)
  172. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFArray of CFString
  173. var kCFDateFormatterMonthSymbols: CFStringRef; external name '_kCFDateFormatterMonthSymbols'; (* attribute const *)
  174. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFArray of CFString
  175. var kCFDateFormatterShortMonthSymbols: CFStringRef; external name '_kCFDateFormatterShortMonthSymbols'; (* attribute const *)
  176. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFArray of CFString
  177. var kCFDateFormatterWeekdaySymbols: CFStringRef; external name '_kCFDateFormatterWeekdaySymbols'; (* attribute const *)
  178. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFArray of CFString
  179. var kCFDateFormatterShortWeekdaySymbols: CFStringRef; external name '_kCFDateFormatterShortWeekdaySymbols'; (* attribute const *)
  180. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFArray of CFString
  181. var kCFDateFormatterAMSymbol: CFStringRef; external name '_kCFDateFormatterAMSymbol'; (* attribute const *)
  182. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFString
  183. var kCFDateFormatterPMSymbol: CFStringRef; external name '_kCFDateFormatterPMSymbol'; (* attribute const *)
  184. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // CFString
  185. // See CFLocale.h for these calendar constants:
  186. // const CFStringRef kCFGregorianCalendar;
  187. // const CFStringRef kCFBuddhistCalendar;
  188. // const CFStringRef kCFJapaneseCalendar;
  189. // const CFStringRef kCFIslamicCalendar;
  190. // const CFStringRef kCFIslamicCivilCalendar;
  191. // const CFStringRef kCFHebrewCalendar;
  192. // const CFStringRef kCFChineseCalendar;
  193. {#endif}
  194. end.