Skip to content

Commit

Permalink
Added "minimumDurationOfAKontestInMinutes" and a comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushs-2k4 committed Jan 12, 2024
1 parent 1617f9c commit 04b9635
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file not shown.
5 changes: 4 additions & 1 deletion Kontest/Utilities/CalendarUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ enum CalendarUtility {
formatter.allowedUnits = [.day, .hour, .minute, .second]

let dateComponents = DateComponents(hour: hours, minute: minutes)

let totalMinutes = (dateComponents.hour ?? 0) * 60 + (dateComponents.minute ?? 0)

let ans = dateComponents.hour ?? 1 <= Constants.maximumDurationOfAKontestInHours ? formatter.string(from: dateComponents) : nil
let ans = ((totalMinutes <= Constants.maximumDurationOfAKontestInMinutes) && (totalMinutes >= Constants.minimumDurationOfAKontestInMinutes)) ? formatter.string(from: dateComponents) : nil // It verifies that kontest duration is in between minimum and maximum range, and if it is not in range then returns nil. If it is nil then in "AllKontestsViewModel", during filtering it removes that kontest entry.

return ans
}

Expand Down
3 changes: 2 additions & 1 deletion Kontest/Utilities/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation

struct Constants {
static let minutesToBeReminderBefore = 10
static let maximumDurationOfAKontestInHours = 360
static let maximumDurationOfAKontestInMinutes = 360 * 60
static let minimumDurationOfAKontestInMinutes = 0
static let userDefaultsGroupID = "group.com.ayushsinghal.kontest"
}

0 comments on commit 04b9635

Please sign in to comment.