Created
April 17, 2018 13:55
-
-
Save wadouk/26d0668d89a32b4c3a28a15daaab2493 to your computer and use it in GitHub Desktop.
Convertir les talks de mixit 2018 en ical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ics = require('ics') | |
const {parse, format} = require('date-fns') | |
const fs = require('fs') | |
const path = require('path') | |
var events = fs.readFileSync(path.join(__dirname, 'talks_2018.json')) | |
function date2array(d) { | |
var d0 = parse(d) | |
return [d0.getFullYear(), d0.getMonth() + 1, d0.getDate(), d0.getHours(), d0.getMinutes()] | |
} | |
ics.createEvents(JSON.parse(events).map(e => { | |
return { | |
title: `${e.title} ${e.language === 'ENGLISH' ? '(en)': ''}`, | |
description: [e.description, e.summary].filter(Boolean).join('\n\n'), | |
start: date2array(e.start), | |
end: date2array(e.end), | |
location : e.room, | |
attendees: e.speakerIds.map(s => {return {name: s}}).filter(Boolean) | |
} | |
}), (error, value) => { | |
if (error) { | |
console.error('fail', error) | |
return; | |
} | |
fs.writeSync(fs.openSync(path.join(__dirname, 'events.ics'), 'w'), value) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ical-mixit", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"date-fns": "^1.29.0", | |
"ics": "^2.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment