I have a hotel reservation application that displays a calendar with the ability to scroll to the user. Now the ultimate goal is to provide a calendar-like interface with small dots under each reserved date. At the moment, I'm just trying to print on the console all the reserves between the start and end dates (where the start and end dates are the beginning and end of the month, respectively).
However, I cannot get this to work with Firebase. Here's how the data is on Firebase at the moment:
{
"reservations" : {
"-KSgRjwpssoZJWjV9ScM" : {
"checkin" : 1474950600,
"checkout" : 1475116200,
"customer" : "-KMVMMudWJlFeiimtgJl"
}
}
}
And here is my Swift code to retrieve the data:
private var ref: FIRDatabaseReference!
ref = FIRDatabase.database().reference()
ref.keepSynced(true)
DispatchQueue.global().async {
print("Fetching Reservations")
print(startDate.timeIntervalSince1970)
print(endDate.timeIntervalSince1970)
self.ref.child("reservations").queryStarting(atValue: startDate.timeIntervalSince1970, childKey: "checkin").observe(.childAdded, with: { (snapshot) -> Void in
print("Data Retrieved.\n")
print(snapshot)
})
}
Here is what is now displayed on the console:
Fetching Reservations
1469989800.0
1472581800.0
Fetching Reservations
1472668200.0
1475173800.0
Since it is clearly visible that the data falls into the second range, but I still can not display it.
What could be wrong here? Thank you