Skip to content

Commit

Permalink
Merge pull request #28 from OneBusAway/Issue-27-add_function_to_gener…
Browse files Browse the repository at this point in the history
…ate_todays_date

Add Tomorrow's Date Function to Fetch Open Trip Planner
  • Loading branch information
aaronbrethorst authored Jul 14, 2024
2 parents 092345a + 9799bd7 commit dd2b683
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion OTPKitDemo/TripPlannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct TripPlannerView: View {
fromPlace: "47.6097,-122.3331",
toPlace: "47.6154,-122.3208",
time: "8:00 AM",
date: "07-05-2024",
date: getFormattedTomorrowDate(),
mode: "TRANSIT,WALK",
arriveBy: false,
maxWalkDistance: 800,
Expand All @@ -55,6 +55,14 @@ struct TripPlannerView: View {
}
}
}

private func getFormattedTomorrowDate() -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: Date())!

return dateFormatter.string(from: tomorrow)
}
}

// For preview and testing
Expand Down

0 comments on commit dd2b683

Please sign in to comment.