Please Suggest me i want to go in 15 minute intervals. ex: 4:00, 4:15, 4:30, 4:45 and so next.
@IBAction func sliderMoved(sender: UISlider) {
let slot = Double(sender.value)
let slotDate = self.timeFromSlot(slot)
print(timeFormatter.stringFromDate(slotDate!))
}
private func timeFromSlot(slot:Double) -> NSDate? {
let cal = NSCalendar.currentCalendar()
let unit:NSCalendarUnit = [.Year, .Month, .Day, .Hour, .Minute, .Second]
let comps = cal.components(unit, fromDate: NSDate())
comps.hour = Int((slot % (24 * 3600)) / 3600)
comps.minute = Int(slot % 3600 / 60)
comps.second = 0
let startedDate = cal.dateFromComponents(comps)!
return startedDate
}
I have sliderMoved that starting point is 8:00 AM and end point 9:00 PM i have set slider min value 28,800 and max value 75,600, When i slide the slider the value is change with my timeFromSlot method and the changed value i got in between 8:01 8:02 8:03.. and i want changed value 8:00 8:15 8:30 like this.
It should be something like
For you case, it's better to use some portions scaling. try this code below. I believe it's pretty straightforward.