func startOfTheMonth(month: Int, year: Int) -> Date? { var components = DateComponents() let calendar = Calendar.current // Extract the year and month from the given date // Set the components to the first day of the next month components.year = year components.month = month components.day = 1 // Get the date that's one second before the first second of the next month return calendar.date(from: components) }let currentDate = Date() let nameFormatter = DateFormatter() nameFormatter.dateFormat = "MMMM" // format January, February, March, ... let name = nameFormatter.string(from: currentDate) let index = Calendar.current.component(.month, from: currentDate) // format 1, 2, 3, ... print(name) // April print(index) // 4