Skip to content

Instantly share code, notes, and snippets.

@jadwigo
Last active July 11, 2016 16:06
Show Gist options
  • Save jadwigo/9c68593964984b5d4829682147f9dbdc to your computer and use it in GitHub Desktop.
Save jadwigo/9c68593964984b5d4829682147f9dbdc to your computer and use it in GitHub Desktop.
datum voor FormatGoogleCalendar
// zet huidige maand aan
var todaydate = new Date();
var current_day = todaydate.getDate();
var current_year = todaydate.getFullYear();
var current_month = todaydate.getMonth();
if(current_month < 10) {
current_month = '0' + current_month;
}
// zet volgende maand aan
var nextmonth = new Date(current_year, current_month + 1, current_day);
var next_month_day = nextmonth.getDate();
var next_month_year = nextmonth.getFullYear();
var next_month_month = nextmonth.getMonth();
if(next_month_month < 10) {
next_month_month = '0' + next_month_month;
}
// bouw de goede url op basis van de 1e van de maand
var starttijd = current_year + '-'+ current_month + '-01T00:00:00Z';
var eindtijd = next_month_year + '-' + next_month_month + '-01T00:00:00Z';
console.log('vandaag', todaydate.toISOString() ,'start', starttijd, 'eind', eindtijd);
// op basis van vandaag + 1 maand
// var starttijd = todaydate.toISOString();
// var eindtijd = nextmonth.toISOString()
var datumurl = 'https://www.googleapis.com/calendar/v3/calendars/musissacrum%40gmail.com/events?maxResults=500&timeMin=' + starttijd + '&timeMax=' + eindtijd + '&key=AIzaSyA-PEK5eCO0exrV0XajdJEs0-rrdSWZGuA';
formatGoogleCalendar.init({
calendarUrl: datumurl,
past: false,
upcoming: true,
sameDayTimes: true,
pastTopN: 0,
upcomingTopN: 10,
itemsTagName: 'div',
upcomingSelector: '#events-upcoming',
pastSelector: '#events-past',
upcomingHeading: '<h2>Upcoming events</h2>',
pastHeading: '<h2>Past events</h2>',
format: ['*date*', '*summary*', ' — ', '*description*', ' in ', '*location*']
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment