From 8aaa2e98bdcea24b1855cf4a48b497a23d614950 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sun, 24 Mar 2024 19:21:27 -0400 Subject: [PATCH] Update ParentPanelController+ModernSlider.swift --- .../Panel/ParentPanelController+ModernSlider.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Clocker/Panel/ParentPanelController+ModernSlider.swift b/Clocker/Panel/ParentPanelController+ModernSlider.swift index fb37231..27aae8f 100644 --- a/Clocker/Panel/ParentPanelController+ModernSlider.swift +++ b/Clocker/Panel/ParentPanelController+ModernSlider.swift @@ -128,6 +128,14 @@ extension ParentPanelController { direction: .forward)! return hourQuarterDate } + + func minutesToHoursAndMinutes(_ minutes: Int) -> (hours: Int , leftMinutes: Int) { + var minutesRemaining = (minutes % 60) + if (minutesRemaining < 0) { + minutesRemaining.negate() + } + return (minutes / 60, minutesRemaining) + } public func setDefaultDateLabel(_ index: Int) -> Int { let futureSliderDayPreference = DataStore.shared().retrieve(key: CLFutureSliderRange) as? NSNumber ?? 5 @@ -137,7 +145,8 @@ extension ParentPanelController { if index >= (centerPoint + 1) { let remainder = (index % (centerPoint + 1)) let nextDate = Calendar.current.date(byAdding: .minute, value: remainder * 15, to: closestQuarterTimeRepresentation ?? Date())! - modernSliderLabel.stringValue = timezoneFormattedStringRepresentation(nextDate) + let minutes = minutesToHoursAndMinutes(remainder * 15) + modernSliderLabel.stringValue = "+\(minutes.hours).\(minutes.leftMinutes)h" if resetModernSliderButton.isHidden { animateButton(false) } @@ -147,6 +156,8 @@ extension ParentPanelController { let remainder = centerPoint - index + 1 let previousDate = Calendar.current.date(byAdding: .minute, value: -1 * remainder * 15, to: closestQuarterTimeRepresentation ?? Date())! modernSliderLabel.stringValue = timezoneFormattedStringRepresentation(previousDate) + let minutes = minutesToHoursAndMinutes(-1 * remainder * 15) + modernSliderLabel.stringValue = "\(minutes.hours).\(minutes.leftMinutes)h" if resetModernSliderButton.isHidden { animateButton(false) }