summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLClockDirectionFormatter.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-24 23:38:49 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-24 23:38:49 -0700
commitbf313b0c5fb17569ba69be63bfc8af41fd5cffa6 (patch)
tree7dbc3229018c01bb036fce0ec8fc75301abb45b0 /platform/darwin/src/MGLClockDirectionFormatter.m
parent57f0a211251a9378fa004ee22b2c6f4d21e2bd59 (diff)
downloadqtlocation-mapboxgl-bf313b0c5fb17569ba69be63bfc8af41fd5cffa6.tar.gz
[ios, osx] Fixed direction formatter edge cases
Fixed an issue causing angles that are multiples of 360°, such as 720°, to be described as 0 o’clock. Fixed a crash when a compass direction is close enough to 360° to round up to 360°.
Diffstat (limited to 'platform/darwin/src/MGLClockDirectionFormatter.m')
-rw-r--r--platform/darwin/src/MGLClockDirectionFormatter.m5
1 files changed, 4 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLClockDirectionFormatter.m b/platform/darwin/src/MGLClockDirectionFormatter.m
index c8c07487ba..fd67968e65 100644
--- a/platform/darwin/src/MGLClockDirectionFormatter.m
+++ b/platform/darwin/src/MGLClockDirectionFormatter.m
@@ -19,7 +19,10 @@
}
- (NSString *)stringFromDirection:(CLLocationDirection)direction {
- NSInteger hour = round(-wrap(-direction, -360, 0) / 360 * 12);
+ NSInteger hour = round(wrap(direction, 0, 360) / 360 * 12);
+ if (hour == 0) {
+ hour = 12;
+ }
NSString *format;
switch (self.unitStyle) {
case NSFormattingUnitStyleShort: