Untested final implementation
Supposedly the implementation is over, BUT still needs to be tested.
This commit is contained in:
parent
ce10d5a0d3
commit
6b5dbe85e3
5
calendar_processor.js
Normal file
5
calendar_processor.js
Normal 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);
|
||||
}
|
|
@ -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){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue