I am very new to SwiftUI and writing an iOS app to have the user enter start and end times (using DatePicker) and then extract the time difference into a double which can then be used to calculate the hourly work rate using a formula. So I need diffTime to be converted to a double and enter into a formula that spits out the hourly rate in US dollars.
I think I've called the correct functions, but don't know where to go from here.
I only need hours and minutes to calculate my work rates. I would be preferable to enter times in military time, but don't know how to do that either.
Below is my code so far:
import SwiftUI
struct ContentView: View { @State private var startTime = Date() @State private var endTime = Date() var body: some View { NavigationView { Form { Section(header: Text("Enter Case Times:")) { DatePicker("Start Time", selection: $startTime , displayedComponents: .hourAndMinute) DatePicker("End Time", selection: $endTime, displayedComponents: .hourAndMinute) } Section(header: Text("Case Duration:")) { let diffTime = DateInterval.init(start: startTime, end: endTime) } } .navigationTitle("Rate Calculator") } } }