Skip to content

Commit ff070d6

Browse files
committed
Fix boundary styles outside of Darwin.
1 parent 0eed327 commit ff070d6

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

CoreFoundation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ add_framework(CoreFoundation
145145
StringEncodings.subproj/CFStringEncodingConverterExt.h
146146
URL.subproj/CFURLPriv.h
147147
URL.subproj/CFURLSessionInterface.h
148+
Locale.subproj/CFDateIntervalFormatter.h
148149

149150
# AppServices
150151
AppServices.subproj/CFNotificationCenter.h

CoreFoundation/Locale.subproj/CFDateIntervalFormatter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static void updateFormatter(CFDateIntervalFormatterRef dif) {
151151
CFLog(kCFLogLevelError, CFSTR("udtitvfmt_open failed! Formatter is NULL! -- locale: %s, template: %@, timezone: %@, status: %s"), localeBuffer, unretainedTemplate, unretainedTimeZoneName, u_errorName(status));
152152
}
153153

154+
#if TARGET_OS_MAC
154155
UDateIntervalFormatAttributeValue uDateIntervalMinimizationStyle = UDTITVFMT_MINIMIZE_NONE;
155156
const _CFDateIntervalFormatterBoundaryStyle type = dif->_boundaryStyle;
156157
switch (type) {
@@ -167,6 +168,7 @@ static void updateFormatter(CFDateIntervalFormatterRef dif) {
167168
CFLog(kCFLogLevelError, CFSTR("udtitvfmt_setAttribute failed! Tried to set minimize type: %d and got status code: %s"), (int)dif->_boundaryStyle, u_errorName(status));
168169
}
169170
}
171+
#endif
170172

171173
CFRelease(locale);
172174
CFRelease(timeZone);

CoreFoundation/Locale.subproj/CFDateIntervalFormatter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ typedef CF_ENUM(CFIndex, CFDateIntervalFormatterStyle) {
3333

3434
typedef CF_ENUM(CFIndex, _CFDateIntervalFormatterBoundaryStyle) {
3535
kCFDateIntervalFormatterBoundaryStyleDefault = 0,
36+
#if TARGET_OS_MAC
3637
kCFDateIntervalFormatterBoundaryStyleMinimizeAdjacentMonths = 1,
38+
#endif
3739
};
3840

3941
CF_EXPORT CFDateIntervalFormatterRef CFDateIntervalFormatterCreate(CFAllocatorRef _Nullable allocator, CFLocaleRef _Nullable locale, CFDateIntervalFormatterStyle dateStyle, CFDateIntervalFormatterStyle timeStyle);

Foundation/DateIntervalFormatter.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ internal let kCFDateIntervalFormatterLongStyle = CFDateIntervalFormatterStyle.lo
1717
internal let kCFDateIntervalFormatterFullStyle = CFDateIntervalFormatterStyle.fullStyle
1818

1919
internal let kCFDateIntervalFormatterBoundaryStyleDefault = _CFDateIntervalFormatterBoundaryStyle.cfDateIntervalFormatterBoundaryStyleDefault
20+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
2021
internal let kCFDateIntervalFormatterBoundaryStyleMinimizeAdjacentMonths = _CFDateIntervalFormatterBoundaryStyle.cfDateIntervalFormatterBoundaryStyleMinimizeAdjacentMonths
2122
#endif
23+
#endif
2224

2325
extension DateIntervalFormatter {
2426
// Keep these in sync with CFDateIntervalFormatterStyle.
@@ -60,7 +62,9 @@ internal extension DateIntervalFormatter.BoundaryStyle {
6062
init(_ cfStyle: _CFDateIntervalFormatterBoundaryStyle) {
6163
switch cfStyle {
6264
case kCFDateIntervalFormatterBoundaryStyleDefault: self = .default
65+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
6366
case kCFDateIntervalFormatterBoundaryStyleMinimizeAdjacentMonths: self = .minimizeAdjacentMonths
67+
#endif
6468
default: fatalError()
6569
}
6670
}
@@ -70,7 +74,9 @@ internal extension _CFDateIntervalFormatterBoundaryStyle {
7074
init(_ style: DateIntervalFormatter.BoundaryStyle) {
7175
switch style {
7276
case .default: self = kCFDateIntervalFormatterBoundaryStyleDefault
77+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
7378
case .minimizeAdjacentMonths: self = kCFDateIntervalFormatterBoundaryStyleMinimizeAdjacentMonths
79+
#endif
7480
}
7581
}
7682
}
@@ -126,7 +132,9 @@ open class DateIntervalFormatter: Formatter {
126132

127133
internal enum BoundaryStyle: UInt {
128134
case `default` = 0
135+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
129136
case minimizeAdjacentMonths = 1
137+
#endif
130138
}
131139

132140
internal var boundaryStyle: BoundaryStyle {

0 commit comments

Comments
 (0)