Untested final implementation

Supposedly the implementation is over, BUT still needs to be tested.
This commit is contained in:
Ricardo Henrique Gracini Guiraldelli 2015-08-30 00:56:42 +02:00
parent ce10d5a0d3
commit 6b5dbe85e3
4 changed files with 22 additions and 2 deletions

5
calendar_processor.js Normal file
View file

@ -0,0 +1,5 @@
// connects to Google Calendar and creates an event in the default calendar
// of the account
function create_event(title, date){
CalendarApp.getDefaultCalendar().createAllDayEvent(title, date);
}

View file

@ -3,6 +3,12 @@ var REGEX_DATE = /((\d{1,2}/\d{1,2}/(\d{4}|\d{2}))|(\d{4}-\d{2}-\d{2})|(\d{1,2}(
// ISO format for dates
var DATE_ISO_FORMAT = "yyyy-MM-dd";
// given a date represented as string, returns the date as a Date Javascript
// object using the Datejs library
function get_date(string_date){
Date.parse(string_date);
}
// gets a mathced date from regex and converts to a string in the ISO format
// using the Datejs library
function get_iso_date(matched_date){

View file

@ -21,8 +21,12 @@ function process_email(gmail_message){
var lines_body = break_lines(get_message_text(gmail_message));
for (line in lines_body){
if (has_date(line) && is_paper_deadline(line)){
var iso_date = get_iso_date(get_literal_date(line));
// TODO: create Google Calendar entry
var date = get_date(get_literal_date(line));
var calendar_event = create_event(subject, date);
if (calendar_event == null){
Logger.log("It was not possible to create an event with the following details:\n\tSubject: %s\n\tDate: %s", subject, date);
}
break;
}
}
}

5
main.js Normal file
View file

@ -0,0 +1,5 @@
// main function, which gets all unread GMail messages and process them all
function main(){
Logger.log("Initiating the process of the call for papers emails...");
get_unread_messages(get_unread_threads()).map(process_email);
}