summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLClockDirectionFormatter.m
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLClockDirectionFormatter.m')
-rw-r--r--platform/darwin/src/MGLClockDirectionFormatter.m60
1 files changed, 0 insertions, 60 deletions
diff --git a/platform/darwin/src/MGLClockDirectionFormatter.m b/platform/darwin/src/MGLClockDirectionFormatter.m
deleted file mode 100644
index 922a1db9a2..0000000000
--- a/platform/darwin/src/MGLClockDirectionFormatter.m
+++ /dev/null
@@ -1,60 +0,0 @@
-#import "MGLClockDirectionFormatter.h"
-
-#import "NSBundle+MGLAdditions.h"
-#import "MGLLoggingConfiguration_Private.h"
-
-#define wrap(value, min, max) \
- (fmod((fmod((value - min), (max - min)) + (max - min)), (max - min)) + min)
-
-@implementation MGLClockDirectionFormatter {
- NSNumberFormatter *_numberFormatter;
-}
-
-- (instancetype)init {
- if (self = [super init]) {
- _unitStyle = NSFormattingUnitStyleMedium;
- _numberFormatter = [[NSNumberFormatter alloc] init];
- _numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
- }
- return self;
-}
-
-- (NSString *)stringFromDirection:(CLLocationDirection)direction {
- NSInteger hour = round(wrap(direction, 0, 360) / 360 * 12);
- if (hour == 0) {
- hour = 12;
- }
- NSString *format;
- switch (self.unitStyle) {
- case NSFormattingUnitStyleShort:
- format = NSLocalizedStringWithDefaultValue(@"CLOCK_FMT_SHORT", @"Foundation", nil, @"%@:00", @"Clock position format, short: {hours}:00");
- break;
-
- case NSFormattingUnitStyleMedium:
- format = NSLocalizedStringWithDefaultValue(@"CLOCK_FMT_MEDIUM", @"Foundation", nil, @"%@ o’clock", @"Clock position format, medium: {hours} o’clock");
-
- break;
-
- case NSFormattingUnitStyleLong:
- format = NSLocalizedStringWithDefaultValue(@"CLOCK_FMT_LONG", @"Foundation", nil, @"%@ o’clock", @"Clock position format, long: {hours} o’clock");
- break;
-
- default:
- break;
- }
- return [NSString stringWithFormat:format, [_numberFormatter stringFromNumber:@(hour)]];
-}
-
-- (nullable NSString *)stringForObjectValue:(id)obj {
- if (![obj isKindOfClass:[NSValue class]]) {
- return nil;
- }
- return [self stringFromDirection:[obj doubleValue]];
-}
-
-- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error {
- MGLAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented");
- return NO;
-}
-
-@end