Skip to content

Instantly share code, notes, and snippets.

@pipwilson
Created June 16, 2013 21:44
Show Gist options
  • Save pipwilson/5793547 to your computer and use it in GitHub Desktop.
Save pipwilson/5793547 to your computer and use it in GitHub Desktop.
convert the list of versions from JIRA into an iCalendar file you can add in Google Calendar
<?php
$versions_url = 'http://HOSTNAME.atlassian.net/rest/api/2/project/KEY/versions?os_username=USERNAME&os_password=PASSWORD';
$versions_file = file_get_contents($versions_url);
$versions = json_decode($versions_file);
start_calendar();
foreach ($versions as $version) {
make_event($version);
}
end_calendar();
function start_calendar() {
echo 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
';
}
function make_event($version) {
$event = 'BEGIN:VEVENT
SUMMARY:'.$version->{'name'}.'
DESCRIPTION:'.$version->{'description'}.' ('.($version->{'released'}==false ? 'not yet ' : '').'released)
DTSTART:'.dateToCal($version->{'startDate'}).'
DTEND:'.dateToCal($version->{'releaseDate'}).'
END:VEVENT
';
echo $event;
}
function end_calendar() {
echo 'END:VCALENDAR';
}
// there is probably a much slicker way of doing this
function dateToCal($time) {
$date = date_create($time);
return date_format($date, 'Ymd\This').'Z';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment