I have this piece of code that gets appointment times and dates from a http request :
$scope.contents = data;
angular.forEach($scope.contents, function(item){
item.Appointment = moment(item.Appointment).format('MM/DD/YYYY');
var d = moment(item.Appointment).format('MM/DD/YYYY');
var t = item.txtTime;
appointmentsArr.push(d + " " + t);
})
My result is :
[ '03/05/2016 4:29:00 PM',
'04/05/2016 11:23:00 AM',
'04/05/2016 11:22:00 AM',
'05/04/2016 10:52:00 AM',
'05/03/2016 9:36:00 AM',
'04/29/2016 12:53:00 PM',
'04/05/2016 11:19:00 AM',
'04/30/2016 12:54:00 AM',
'01/01/1900 12:00:00 AM',
'04/30/2016 8:52:00 AM' ]
My question is, is it possible to kind of group this data so that i can check if an appointment exists already? i want to bring up an error if there is an appointment within an hour of the time on that date..
so would the dates be an array with the times inside? i imaging it would be something like the below sudo?
[ [03/05/2016] 4:29:00 PM',
[04/05/2016] '11:23:00 AM,11:22:00 AM,12:53:00 PM'
[05/04/2016] 10:52:00 AM ]
How could i achieve this?