| 1 |
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT |
| 2 |
// file at the top-level directory of this distribution. |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 |
// option. This file may not be copied, modified, or distributed |
| 8 |
// except according to those terms. |
| 9 |
|
| 10 |
use std::os::raw::c_void; |
| 11 |
|
| 12 |
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef}; |
| 13 |
use crate::date::{CFAbsoluteTime, CFDateRef}; |
| 14 |
use crate::locale::CFLocaleRef; |
| 15 |
use crate::string::CFStringRef; |
| 16 |
|
| 17 |
#[repr(C)] |
| 18 |
pub struct __CFDateFormatter(c_void); |
| 19 |
pub type CFDateFormatterRef = *mut __CFDateFormatter; |
| 20 |
|
| 21 |
pub type CFDateFormatterKey = CFStringRef; |
| 22 |
pub type CFDateFormatterStyle = CFIndex; |
| 23 |
pub type CFISO8601DateFormatOptions = CFOptionFlags; |
| 24 |
|
| 25 |
/* Date Formatter Styles */ |
| 26 |
pub const kCFDateFormatterNoStyle: CFDateFormatterStyle = 0; |
| 27 |
pub const kCFDateFormatterShortStyle: CFDateFormatterStyle = 1; |
| 28 |
pub const kCFDateFormatterMediumStyle: CFDateFormatterStyle = 2; |
| 29 |
pub const kCFDateFormatterLongStyle: CFDateFormatterStyle = 3; |
| 30 |
pub const kCFDateFormatterFullStyle: CFDateFormatterStyle = 4; |
| 31 |
|
| 32 |
//pub const kCFISO8601DateFormatWithYear: CFISO8601DateFormatOptions = 1 << 0; // macosx(10.12)+ |
| 33 |
//pub const kCFISO8601DateFormatWithMonth: CFISO8601DateFormatOptions = 1 << 1; // macosx(10.12)+ |
| 34 |
//pub const kCFISO8601DateFormatWithWeekOfYear: CFISO8601DateFormatOptions = 1 << 2; // macosx(10.12)+ |
| 35 |
//pub const kCFISO8601DateFormatWithDay: CFISO8601DateFormatOptions = 1 << 4; // macosx(10.12)+ |
| 36 |
//pub const kCFISO8601DateFormatWithTime: CFISO8601DateFormatOptions = 1 << 5; // macosx(10.12)+ |
| 37 |
//pub const kCFISO8601DateFormatWithTimeZone: CFISO8601DateFormatOptions = 1 << 6; // macosx(10.12)+ |
| 38 |
//pub const kCFISO8601DateFormatWithSpaceBetweenDateAndTime: CFISO8601DateFormatOptions = 1 << 7; // macosx(10.12)+ |
| 39 |
//pub const kCFISO8601DateFormatWithDashSeparatorInDate: CFISO8601DateFormatOptions = 1 << 8; // macosx(10.12)+ |
| 40 |
//pub const kCFISO8601DateFormatWithColonSeparatorInTime: CFISO8601DateFormatOptions = 1 << 9; // macosx(10.12)+ |
| 41 |
//pub const kCFISO8601DateFormatWithColonSeparatorInTimeZone: CFISO8601DateFormatOptions = 1 << 10; // macosx(10.12)+ |
| 42 |
//pub const kCFISO8601DateFormatWithFractionalSeconds: CFISO8601DateFormatOptions = 1 << 11; // macosx(10.13)+ |
| 43 |
//pub const kCFISO8601DateFormatWithFullDate: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithYear | kCFISO8601DateFormatWithMonth | kCFISO8601DateFormatWithDay | kCFISO8601DateFormatWithDashSeparatorInDate; // macosx(10.12)+ |
| 44 |
//pub const kCFISO8601DateFormatWithFullTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithTime | kCFISO8601DateFormatWithColonSeparatorInTime | kCFISO8601DateFormatWithTimeZone | kCFISO8601DateFormatWithColonSeparatorInTimeZone; // macosx(10.12)+ |
| 45 |
//pub const kCFISO8601DateFormatWithInternetDateTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithFullDate | kCFISO8601DateFormatWithFullTime; // macosx(10.12)+ |
| 46 |
|
| 47 |
extern "C" { |
| 48 |
/* |
| 49 |
* CFDateFormatter.h |
| 50 |
*/ |
| 51 |
|
| 52 |
/* Date Formatter Property Keys */ |
| 53 |
// The values for these keys are all CFType objects. |
| 54 |
// The specific types for each key are specified above. |
| 55 |
pub static kCFDateFormatterIsLenient: CFDateFormatterKey; // CFBoolean |
| 56 |
pub static kCFDateFormatterTimeZone: CFDateFormatterKey; // CFTimeZone |
| 57 |
pub static kCFDateFormatterCalendarName: CFDateFormatterKey; // CFString |
| 58 |
pub static kCFDateFormatterDefaultFormat: CFDateFormatterKey; // CFString |
| 59 |
pub static kCFDateFormatterTwoDigitStartDate: CFDateFormatterKey; // CFDate |
| 60 |
pub static kCFDateFormatterDefaultDate: CFDateFormatterKey; // CFDate |
| 61 |
pub static kCFDateFormatterCalendar: CFDateFormatterKey; // CFCalendar |
| 62 |
pub static kCFDateFormatterEraSymbols: CFDateFormatterKey; // CFArray of CFString |
| 63 |
pub static kCFDateFormatterMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 64 |
pub static kCFDateFormatterShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 65 |
pub static kCFDateFormatterWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 66 |
pub static kCFDateFormatterShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 67 |
pub static kCFDateFormatterAMSymbol: CFDateFormatterKey; // CFString |
| 68 |
pub static kCFDateFormatterPMSymbol: CFDateFormatterKey; // CFString |
| 69 |
pub static kCFDateFormatterLongEraSymbols: CFDateFormatterKey; // CFArray of CFString |
| 70 |
pub static kCFDateFormatterVeryShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 71 |
pub static kCFDateFormatterStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 72 |
pub static kCFDateFormatterShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 73 |
pub static kCFDateFormatterVeryShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString |
| 74 |
pub static kCFDateFormatterVeryShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 75 |
pub static kCFDateFormatterStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 76 |
pub static kCFDateFormatterShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 77 |
pub static kCFDateFormatterVeryShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString |
| 78 |
pub static kCFDateFormatterQuarterSymbols: CFDateFormatterKey; // CFArray of CFString |
| 79 |
pub static kCFDateFormatterShortQuarterSymbols: CFDateFormatterKey; // CFArray of CFString |
| 80 |
pub static kCFDateFormatterStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString |
| 81 |
pub static kCFDateFormatterShortStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString |
| 82 |
pub static kCFDateFormatterGregorianStartDate: CFDateFormatterKey; // CFDate |
| 83 |
pub static kCFDateFormatterDoesRelativeDateFormattingKey: CFDateFormatterKey; // CFBoolean |
| 84 |
|
| 85 |
/* Creating a Date Formatter */ |
| 86 |
pub fn CFDateFormatterCreate( |
| 87 |
allocator: CFAllocatorRef, |
| 88 |
locale: CFLocaleRef, |
| 89 |
dateStyle: CFDateFormatterStyle, |
| 90 |
timeStyle: CFDateFormatterStyle, |
| 91 |
) -> CFDateFormatterRef; |
| 92 |
|
| 93 |
/* Configuring a Date Formatter */ |
| 94 |
pub fn CFDateFormatterSetFormat(formatter: CFDateFormatterRef, formatString: CFStringRef); |
| 95 |
pub fn CFDateFormatterSetProperty( |
| 96 |
formatter: CFDateFormatterRef, |
| 97 |
key: CFStringRef, |
| 98 |
value: CFTypeRef, |
| 99 |
); |
| 100 |
|
| 101 |
/* Parsing Strings */ |
| 102 |
pub fn CFDateFormatterCreateDateFromString( |
| 103 |
allocator: CFAllocatorRef, |
| 104 |
formatter: CFDateFormatterRef, |
| 105 |
string: CFStringRef, |
| 106 |
rangep: *mut CFRange, |
| 107 |
) -> CFDateRef; |
| 108 |
pub fn CFDateFormatterGetAbsoluteTimeFromString( |
| 109 |
formatter: CFDateFormatterRef, |
| 110 |
string: CFStringRef, |
| 111 |
rangep: *mut CFRange, |
| 112 |
atp: *mut CFAbsoluteTime, |
| 113 |
) -> Boolean; |
| 114 |
|
| 115 |
/* Creating Strings From Data */ |
| 116 |
pub fn CFDateFormatterCreateStringWithAbsoluteTime( |
| 117 |
allocator: CFAllocatorRef, |
| 118 |
formatter: CFDateFormatterRef, |
| 119 |
at: CFAbsoluteTime, |
| 120 |
) -> CFStringRef; |
| 121 |
pub fn CFDateFormatterCreateStringWithDate( |
| 122 |
allocator: CFAllocatorRef, |
| 123 |
formatter: CFDateFormatterRef, |
| 124 |
date: CFDateRef, |
| 125 |
) -> CFStringRef; |
| 126 |
pub fn CFDateFormatterCreateDateFormatFromTemplate( |
| 127 |
allocator: CFAllocatorRef, |
| 128 |
tmplate: CFStringRef, |
| 129 |
options: CFOptionFlags, |
| 130 |
locale: CFLocaleRef, |
| 131 |
) -> CFStringRef; |
| 132 |
|
| 133 |
/* Getting Information About a Date Formatter */ |
| 134 |
pub fn CFDateFormatterCopyProperty( |
| 135 |
formatter: CFDateFormatterRef, |
| 136 |
key: CFDateFormatterKey, |
| 137 |
) -> CFTypeRef; |
| 138 |
pub fn CFDateFormatterGetDateStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle; |
| 139 |
pub fn CFDateFormatterGetFormat(formatter: CFDateFormatterRef) -> CFStringRef; |
| 140 |
pub fn CFDateFormatterGetLocale(formatter: CFDateFormatterRef) -> CFLocaleRef; |
| 141 |
pub fn CFDateFormatterGetTimeStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle; |
| 142 |
|
| 143 |
/* Getting the CFDateFormatter Type ID */ |
| 144 |
pub fn CFDateFormatterGetTypeID() -> CFTypeID; |
| 145 |
|
| 146 |
//pub fn CFDateFormatterCreateISO8601Formatter(allocator: CFAllocatorRef, formatOptions: CFISO8601DateFormatOptions) -> CFDateFormatterRef; // macosx(10.12)+ |
| 147 |
} |