Created
November 30, 2020 20:28
-
-
Save mrmemmo/c764a8fbf86af97052d9c0dd8db365bb to your computer and use it in GitHub Desktop.
unbook.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func unBook(hrs: String){ | |
let calendar = Calendar.current | |
let components = calendar.dateComponents([.day], from: selectedDate) | |
let dayOfMonth = components.day | |
let components2 = calendar.dateComponents([.month], from: selectedDate) | |
let monthOfY = components2.month | |
var spotBooked = timeSlots(name: "Available", time: "\(hrs) PM", hour: Int(hrs)! , day:dayOfMonth!, month:monthOfY!, year:2020); | |
// self.theTimes.append(spotBooked) | |
var count1 = 0; | |
var spotter = 0; | |
for spot in self.theTimes { | |
if(spot.hour == (Int(hrs)!) && spot.month == (monthOfY!) && spot.day == (dayOfMonth!) ){ | |
self.theTimes[count1] = spotBooked; | |
spotter = count1; | |
} | |
count1 = count1 + 1 | |
} | |
self.theTimes.remove(at: spotter) | |
var ts = timeSlots(name: "Available", time: "\(hrs) PM", hour: Int(hrs)!, day:1, month:1, year:1); | |
var count = 0; | |
for spot2 in self.theTimeSlots { | |
if(count==(Int(hrs)!-3)){ | |
self.theTimeSlots[count] = ts; | |
} | |
count = count + 1 | |
} | |
/* | |
var db = Firestore.firestore() | |
var ref: DocumentReference? = nil | |
ref = db.collection("bookings").addDocument(data: [ | |
"email": Auth.auth().currentUser?.email, | |
"time": selectedDate, | |
"hour": hrs | |
]) { err in | |
if let err = err { | |
print("Error adding document: \(err)") | |
} else { | |
print("Document added with ID: \(ref!.documentID)") | |
} | |
} | |
*/ | |
}//unbooked |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment