0.0.1 • Published 8 years ago

eventcalendarjs v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

getMonth(date, startingDay) function returns a calendar object for the month of date object passed in, and startingDay is the day of the week you want your calendar to start on (0 = Sunday, 1 = Monday, 2 = Tuesday,3 = Wednesday,4 = Thursday,5 = Friday,6 = Saturday).

Calendar object includes details of first day of the month, number of days in month, and number of weeks required to display month on calendar with a break down off all weeks and days of the week. If the first and/or last week of the month include dates from previous/next month details of those days are also included.

each day has an "isToday". "Yes" signals that the day is todays date.

Sample month returned:

{
"firstDay": "Friday",
"monthLenght": 30,
"calendarWeeks": 5,
"week1": {
    "day1": {
        "day": 28,
        "month": 2,
        "year": 2016,
        "date": "2016-03-27T23:00:00.000Z",
        "isToday": "No"
    },
    "day2": {
        "day": 29,
        "month": 2,
        "year": 2016,
        "date": "2016-03-28T23:00:00.000Z",
        "isToday": "No"
    },
    "day3": {
        "day": 30,
        "month": 2,
        "year": 2016,
        "date": "2016-03-29T23:00:00.000Z",
        "isToday": "No"
    },
    "day4": {
        "day": 31,
        "month": 2,
        "year": 2016,
        "date": "2016-03-30T23:00:00.000Z",
        "isToday": "No"
    },
    "day5": {
        "day": 1,
        "month": 3,
        "year": 2016,
        "date": "2016-03-31T23:00:00.000Z",
        "isToday": "No"
    },
    "day6": {
        "day": 2,
        "month": 3,
        "year": 2016,
        "date": "2016-04-01T23:00:00.000Z",
        "isToday": "Yes"
    },
    "day7": {
        "day": 3,
        "month": 3,
        "year": 2016,
        "date": "2016-04-02T23:00:00.000Z",
        "isToday": "No"
    }
},
"week2": {
    ... etc.

Sample code to loop through and print out calendar

//variable to hold table body
var tableBody = "";
//jQuery AJAX call for JSON
$.getJSON('month/1/' + month + '/' + year, function (data) {
    //loop through weeks (based on how many weeks are needed to print full month)
    for (var weekNo = 1; weekNo <= data['calendarWeeks']; weekNo++) {
        //Print out details for each day of week
        tableBody += '<tr>';
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day1']['day'] + '</div></td>';            
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day2']['day'] + '</div></td>';            
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day3']['day'] + '</div></td>';         
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day4']['day'] + '</div></td>';            
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day5']['day'] + '</div></td>';            
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day6']['day'] + '</div></td>';            
            tableBody += '<td><div class="dateNumber">' + data['week' + weekNo]['day7']['day'] + '</div></td>';            
        tableBody += '</tr>';
    }
    //print out calendar
    document.getElementById('tableBody').innerHTML = tableBody;
});

Similarily the getWeek(date, startingDay) function returns a week object, starting on a chosen day, with a break down of each day based on date passed in

0.0.1

8 years ago

1.0.691

8 years ago

1.0.69

8 years ago

1.0.681

8 years ago

1.0.855

8 years ago

1.0.85

8 years ago

1.0.8

8 years ago

1.0.75

8 years ago

1.0.7

8 years ago

1.0.611

8 years ago

1.0.61

8 years ago

1.0.6

8 years ago

1.0.152

8 years ago

1.0.151

8 years ago

1.0.2

8 years ago

1.0.15

8 years ago

1.0.149

8 years ago

1.0.148

8 years ago

1.0.147

8 years ago

1.0.146

8 years ago

1.0.145

8 years ago

1.0.144

8 years ago

1.0.143

8 years ago

1.0.141

8 years ago

1.0.14

8 years ago

1.0.133112

8 years ago

1.0.13311

8 years ago

1.0.1331

8 years ago

1.0.133

8 years ago

1.0.13213121

8 years ago

1.0.1321312

8 years ago

1.0.132131

8 years ago

1.0.13213

8 years ago

1.0.1321

8 years ago

1.0.132

8 years ago

1.0.131

8 years ago

1.0.13

8 years ago

1.0.121212121212

8 years ago

1.0.12121212121

8 years ago

1.0.1212121212

8 years ago

1.0.121212121

8 years ago

1.0.12121212

8 years ago

1.0.1212121

8 years ago

1.0.121212

8 years ago

1.0.12121

8 years ago

1.0.1212

8 years ago

1.0.121

8 years ago

1.0.12

8 years ago

1.0.1121111

8 years ago

1.0.112111

8 years ago

1.0.11211

8 years ago

1.0.1121

8 years ago

1.0.112

8 years ago

1.0.11

8 years ago

1.0.0

8 years ago