I am trying to create a room availability script for a conference room at my university. I decided to achieve it using jQuery by parsing a JSON feed of a public Google calendar and then displaying on the screen whether room is available or not.

I feel stupid, I have been fighting this problems for 3 days and no matter whether there is an appointment in Google calendar or not the script says that room is available. Could anyone offer a suggestion why this may be happening. I am not a programmer and I bet this is something really simple but I just can't seem to see it. Any help would be greatly appreciated!

A minimal working example on [jsFiddle](http://jsfiddle.net/Mf8vb/1/) and below:

```
<html>
<head>
<title>Graduate Center Conference Room</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
// Declare global variables

var events = [];
var currentReservation = null;
var nextReservation = null;
var gclaData = 'http://www.google.com/calendar/feeds/4occ2bc4m626a3pgmirlm06q5s%40group.calendar.google.com/public/full?orderby=starttime&sortorder=ascending&futureevents=true&singleevents=true&max-results=2&alt=json';

// Parse Google Calendar Public JSON Feed and store in the events global array

$(document).ready(function () {
$.getJSON(gclaData, function (data) {
    $.each(data.feed.entry, function (i, entry) {
        var dtStart = new Date(entry["gd$when"][0].startTime);
        var dtEnd = new Date(entry["gd$when"][0].endTime);
        var dtSummary = entry.content.$t;
        var dtTitle = entry.title.$t;

        events[i] = {
            'start': dtStart,
                'end': dtEnd,
                'title': dtTitle,
                'summary': dtSummary
        };
    });
});

reservationInfo = '';

// sort events just in case (JSON should be sorted anyways)    

events.sort(function (a, b) {
    return a.start - b.start;
});

// current date

var dtNow = new Date();

// let's assume there are no current room reservations unless script detects otherwise.
// No reservations indicated by -1
currentReservation = -1;

// loop through the events array and if current time falls between start and end of a element in the array the mark it as a reservation currently in progress 

for (var i in events) {
    if (dtNow >= events[i].start && dtNow <= events[i].end) currentReservation = i;
}

// Print the result to a output div

if (-1 == currentReservation) {

    reservationInfo = '<h1>ROOM AVAILABLE</h1>';
    $('#output').html(reservationInfo);

} else {

    reservationInfo = '<h1>ROOM OCCUPIED</h1>';
    $('#output').html(reservationInfo);
}
});
</script>
</head>
<body>
            <div id="output"></div>
</body>
</html>

```