diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/debian/bzr-builder.manifest maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/debian/bzr-builder.manifest --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/debian/bzr-builder.manifest 2015-11-29 05:17:01.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/debian/bzr-builder.manifest 2015-11-30 05:17:17.000000000 +0000 @@ -1,3 +1,3 @@ -# bzr-builder format 0.3 deb-version {debupstream}+r843+pkg70~daily -lp:maya revid:launchpad_translations_on_behalf_of_elementary-apps-20151129051345-q0uuqfq317g90gs6 +# bzr-builder format 0.3 deb-version {debupstream}+r845+pkg70~daily +lp:maya revid:launchpad_translations_on_behalf_of_elementary-apps-20151130051702-en67ts3te0arvu3z nest-part packaging lp:~elementary-os/maya/deb-packaging debian debian revid:cody@elementaryos.org-20150530142953-r52o0p0twtzusbdr diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/debian/changelog maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/debian/changelog --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/debian/changelog 2015-11-29 05:17:01.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/debian/changelog 2015-11-30 05:17:17.000000000 +0000 @@ -1,8 +1,8 @@ -maya-calendar (0.3.1.1+r843+pkg70~daily~ubuntu16.04.1) xenial; urgency=low +maya-calendar (0.3.1.1+r845+pkg70~daily~ubuntu16.04.1) xenial; urgency=low * Auto build. - -- Launchpad Package Builder Sun, 29 Nov 2015 05:17:01 +0000 + -- Launchpad Package Builder Mon, 30 Nov 2015 05:17:17 +0000 maya-calendar (0.3.1.1) trusty; urgency=medium diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/po/it.po maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/po/it.po --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/po/it.po 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/po/it.po 2015-11-30 05:17:14.000000000 +0000 @@ -8,14 +8,14 @@ "Project-Id-Version: maya\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-23 21:37+0200\n" -"PO-Revision-Date: 2015-11-28 08:06+0000\n" +"PO-Revision-Date: 2015-11-29 11:18+0000\n" "Last-Translator: Fabio Zaramella \n" "Language-Team: Italian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Launchpad-Export-Date: 2015-11-29 05:13+0000\n" +"X-Launchpad-Export-Date: 2015-11-30 05:17+0000\n" "X-Generator: Launchpad (build 17850)\n" "Language: it\n" diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/po/pt.po maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/po/pt.po --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/po/pt.po 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/po/pt.po 2015-11-30 05:17:14.000000000 +0000 @@ -8,15 +8,15 @@ "Project-Id-Version: maya\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-23 21:37+0200\n" -"PO-Revision-Date: 2015-04-19 16:48+0000\n" -"Last-Translator: Jaap Broekhuizen \n" +"PO-Revision-Date: 2015-11-29 22:58+0000\n" +"Last-Translator: Pedro Monteiro \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Launchpad-Export-Date: 2015-10-24 05:23+0000\n" -"X-Generator: Launchpad (build 17812)\n" +"X-Launchpad-Export-Date: 2015-11-30 05:17+0000\n" +"X-Generator: Launchpad (build 17850)\n" "Language: pt\n" #: ../src/SourceDialog/SourceSelector.vala:70 @@ -230,27 +230,27 @@ #: ../src/EventEdition/RepeatPanel.vala:111 msgid "Day" msgid_plural "Days" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Dia" +msgstr[1] "Dias" #: ../src/EventEdition/RepeatPanel.vala:114 #: ../src/EventEdition/RepeatPanel.vala:125 msgid "Week" msgid_plural "Weeks" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Semana" +msgstr[1] "Semanas" #: ../src/EventEdition/RepeatPanel.vala:117 msgid "Month" msgid_plural "Months" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Mês" +msgstr[1] "Meses" #: ../src/EventEdition/RepeatPanel.vala:120 msgid "Year" msgid_plural "Years" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Ano" +msgstr[1] "Anos" #: ../src/EventEdition/RepeatPanel.vala:135 msgid "Ends:" @@ -261,8 +261,8 @@ #: ../src/EventEdition/EventDialog.vala:106 msgid "Repeat" msgid_plural "Repeats" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Repetição" +msgstr[1] "Repetições" #: ../src/EventEdition/RepeatPanel.vala:141 msgid "Never" diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/CMakeLists.txt maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/CMakeLists.txt --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/CMakeLists.txt 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/CMakeLists.txt 2015-11-30 05:17:14.000000000 +0000 @@ -10,6 +10,11 @@ EventEdition/LocationPanel.vala EventEdition/ReminderPanel.vala EventEdition/RepeatPanel.vala + EventParser/EventParser.vala + EventParser/EventParserHandler.vala + EventParser/ParsedEvent.vala + EventParser/Parsers/ParserDe.vala + EventParser/Parsers/ParserEn.vala Grid/CalendarView.vala Grid/GridDay.vala Grid/Grid.vala diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/EventDialog.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/EventDialog.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/EventDialog.vala 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/EventDialog.vala 2015-11-30 05:17:14.000000000 +0000 @@ -126,6 +126,30 @@ } }); + var handler = new Maya.Services.EventParserHandler (); + var parser = handler.get_parser (handler.get_locale ()); + if (handler.get_locale ().contains (parser.get_language ())) { + // If there is handler for the current locale then... + info_panel.nl_parsing_enabled = true; + bool event_parsed = false; + info_panel.parse_event.connect ((ev_str) => { + if (!event_parsed) { + var ev = parser.parse_source (ev_str); + info_panel.title = ev.title; + info_panel.from_date = ev.from; + info_panel.to_date = ev.to; + info_panel.from_time = ev.from; + info_panel.to_time = ev.to; + info_panel.all_day = ev.all_day; + guests_panel.guests = ev.participants; + location_panel.location = ev.location; + event_parsed = true; + } + else + save_dialog (); + }); + } + stack.add_named (info_panel, "infopanel"); stack.add_named (location_panel, "locationpanel"); stack.add_named (guests_panel, "guestspanel"); diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/GuestsPanel.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/GuestsPanel.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/GuestsPanel.vala 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/GuestsPanel.vala 2015-11-30 05:17:14.000000000 +0000 @@ -26,6 +26,11 @@ private Gee.ArrayList attendees; private Gtk.ListStore guest_store; + public string guests { + get { return guest_entry.get_text (); } + set { guest_entry.set_text (value); } + } + private enum COLUMNS { ICON = 0, NAME, diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/InfoPanel.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/InfoPanel.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/InfoPanel.vala 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/InfoPanel.vala 2015-11-30 05:17:14.000000000 +0000 @@ -30,6 +30,40 @@ private EventDialog parent_dialog; + + public string title { + get { return title_entry.get_text (); } + set { title_entry.set_text (value); } + } + + public DateTime from_date { + get { return from_date_picker.date; } + set { from_date_picker.date = value; } + } + + public DateTime to_date { + get { return to_date_picker.date; } + set { to_date_picker.date = value; } + } + + public DateTime from_time { + get { return from_time_picker.time; } + set { from_time_picker.time = value; } + } + + public DateTime to_time { + get { return to_time_picker.time; } + set { to_time_picker.time = value; } + } + + public bool all_day { + get { return allday_switch.get_active (); } + set { allday_switch.set_active (value); } + } + + public bool nl_parsing_enabled = false; + + public signal void parse_event (string event_str); public signal void valid_event (bool is_valid); public InfoPanel (EventDialog parent_dialog) { @@ -74,6 +108,21 @@ title_entry = new Gtk.Entry (); title_entry.placeholder_text = _("Name of Event"); title_entry.changed.connect (on_title_entry_modified); + title_entry.activate.connect (() => { + parse_event (title_entry.get_text ()); + title_entry.secondary_icon_name = null; + title_entry.secondary_icon_tooltip_text = null; + }); + title_entry.changed.connect (() => { + if (title_entry.get_text ().length > 0 && nl_parsing_enabled) { + title_entry.secondary_icon_name = "go-jump-symbolic"; + title_entry.secondary_icon_tooltip_text = _("Press enter to parse event"); + } + else { + title_entry.secondary_icon_name = null; + title_entry.secondary_icon_tooltip_text = null; + } + }); var calendar_label = Maya.View.EventDialog.make_label (_("Calendar:")); calendar_button = new Maya.View.Widgets.CalendarButton (); diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/LocationPanel.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/LocationPanel.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventEdition/LocationPanel.vala 2015-11-29 05:17:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventEdition/LocationPanel.vala 2015-11-30 05:17:14.000000000 +0000 @@ -30,6 +30,11 @@ private bool map_selected = false; private GLib.Cancellable search_cancellable; + public string location { + get { return location_entry.get_text (); } + set { location_entry.set_text (value); } + } + public LocationPanel (EventDialog parent_dialog) { this.parent_dialog = parent_dialog; diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParserHandler.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParserHandler.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParserHandler.vala 1970-01-01 00:00:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParserHandler.vala 2015-11-30 05:17:14.000000000 +0000 @@ -0,0 +1,59 @@ +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- +/*** + BEGIN LICENSE + + Copyright (C) 2015 Mario Guerriero + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License version 3, as published + by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranties of + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see + + END LICENSE +***/ + +namespace Maya.Services { + +public class EventParserHandler : GLib.Object { + + public const string FALLBACK_LANG = "en"; + + private Gee.HashMap handlers; + + public EventParserHandler (string? lang = null) { + handlers = new Gee.HashMap (); + + if (lang == null) + lang = get_locale (); + + // Grant at least the fallback parser + register_handler (FALLBACK_LANG, new ParserEn ()); + + // Register other default parsers + var parser = new ParserDe (); + register_handler (parser.get_language (), parser); // de + + } + + public void register_handler (string lang, EventParser parser) { + handlers.set (lang, parser); + } + + public EventParser get_parser (string lang) { + if (!handlers.has_key (lang)) + return handlers.get (FALLBACK_LANG); + return handlers.get (lang); + } + + public unowned string? get_locale () { + return Environment.get_variable ("LANGUAGE"); + } +} + +} diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParser.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParser.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParser.vala 1970-01-01 00:00:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/EventParser.vala 2015-11-30 05:17:14.000000000 +0000 @@ -0,0 +1,28 @@ +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- +/*** + BEGIN LICENSE + + Copyright (C) 2015 Mario Guerriero + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License version 3, as published + by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranties of + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see + + END LICENSE +***/ + +namespace Maya.Services { + +public interface EventParser : GLib.Object { + public abstract ParsedEvent parse_source (string source); + public abstract string get_language (); +} + +} \ No newline at end of file diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/ParsedEvent.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/ParsedEvent.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/ParsedEvent.vala 1970-01-01 00:00:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/ParsedEvent.vala 2015-11-30 05:17:14.000000000 +0000 @@ -0,0 +1,183 @@ +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- +/*** + BEGIN LICENSE + + Copyright (C) 2015 Mario Guerriero + pantor + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License version 3, as published + by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranties of + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see + + END LICENSE +***/ + +namespace Maya.Services { + +public class ParsedEvent : GLib.Object { + + public string title; + public string location; + public string participants; + public DateTime from; + public DateTime to; + public bool all_day; + + public ParsedEvent (string _title = "", DateTime? _from = null, DateTime? _to = null, string _location = "", bool _all_day = false, string _participants = "") { + this.title = _title; + this.location = _location; + this.participants = _participants; + this.from = _from; + this.to = _to; + this.all_day = _all_day; + } + + public void set_length_to_minutes (int minutes) { + this.to = this.from.add_minutes (minutes); + } + + public void set_length_to_hours (int hours) { + this.to = this.from.add_hours (hours); + } + + public void set_length_to_days (int days) { + this.to = this.from.add_days (days); + } + + public void set_length_to_weeks (int weeks) { + this.to = this.from.add_days (7 * weeks); + } + + public void from_set_second (int second) { + this.from = this.from.add_seconds (second - this.from.get_second ()); + } + + public void to_set_second (int second) { + this.to = this.to.add_seconds (second - this.to.get_second ()); + } + + public void from_set_minute (int minute) { + this.from = this.from.add_minutes (minute - this.from.get_minute ()); + } + + public void to_set_minute (int minute) { + this.to = this.to.add_minutes (minute - this.to.get_minute ()); + } + + private int hour_from_half (int hour, string half) { + if (hour > 12) + return hour; + + if (half == "pm") + return hour + 12; + + if (half == "p") + return hour + 12; + + if (half == "") { + if (hour < 8) { + hour += 12; + } + } + + return hour; + } + + public void from_set_hour (int hour, string half = "") { + hour = hour_from_half (hour, half); + this.from = this.from.add_hours (hour - this.from.get_hour ()); + } + + public void to_set_hour (int hour, string half = "") { + hour = hour_from_half (hour, half); + this.to = this.to.add_hours (hour - this.to.get_hour ()); + } + + public void from_set_day (int day) { + if (day > 0) + this.from = this.from.add_days (day - this.from.get_day_of_month ()); + } + + public void to_set_day (int day) { + if (day > 0) + this.to = this.to.add_days (day - this.to.get_day_of_month ()); + } + + public void from_set_month (int month) { + if (month > 0) + this.from = this.from.add_months (month - this.from.get_month ()); + } + + public void to_set_month (int month) { + if (month > 0) + this.to = this.to.add_months (month - this.to.get_month ()); + } + + public void from_set_year (int year) { + if (year > 0) + this.from = this.from.add_years (year - this.from.get_year ()); + } + + public void to_set_year (int year) { + if (year > 0) + this.to = this.to.add_years (year - this.to.get_year ()); + } + + + + public void set_all_day () { + this.from = this.from.add_hours (-this.from.get_hour () ).add_minutes (-this.from.get_minute ()); + this.to = this.to.add_hours (-this.to.get_hour ()).add_minutes (-this.to.get_minute ()); + this.all_day = true; + } + + public void unset_all_day () { + this.set_length_to_hours (1); + this.all_day = false; + } + + public void set_one_entire_day () { + this.from = this.from.add_hours (-this.from.get_hour ()).add_minutes (-this.from.get_minute ()); + this.to = this.from; + this.all_day = true; + } + + + + public void if_elapsed_delay_to_next_day (DateTime simulated_dt) { + if (this.from.compare (simulated_dt) < 0) { + this.from = this.from.add_days (1); + this.to = this.to.add_days (1); + } + } + + public void if_elapsed_delay_to_next_week (DateTime simulated_dt) { + if (this.from.compare (simulated_dt) < 0) { + this.from = this. from.add_days (7); + this.to = this.to.add_days (7); + } + } + + public void if_elapsed_delay_to_next_month (DateTime simulated_dt) { + if (this.from.compare (simulated_dt) < 0) { + this.from = this.from.add_months (1); + this.to = this.to.add_months (1); + } + } + + public void if_elapsed_delay_to_next_year (DateTime simulated_dt) { + if (this.from.compare (simulated_dt) < 0) { + this.from = this.from.add_years (1); + this.to = this.to.add_years (1); + } + } +} + +} \ No newline at end of file diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserDe.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserDe.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserDe.vala 1970-01-01 00:00:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserDe.vala 2015-11-30 05:17:14.000000000 +0000 @@ -0,0 +1,399 @@ +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- +/*** + BEGIN LICENSE + + Copyright (C) 2015 Mario Guerriero + pantor + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License version 3, as published + by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranties of + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see + + END LICENSE +***/ + +namespace Maya.Services { + +public class ParserDe : GLib.Object, EventParser { + + public DateTime simulated_dt; + + public string source; + private string remaining_source; + + + string[,] months = { + {"januar", "1"}, + {"februar", "2"}, + {"märz", "3"}, + {"april", "4"}, + {"mai", "5"}, + {"juni", "6"}, + {"juli", "7"}, + {"august", "8"}, + {"september", "9"}, + {"oktober", "10"}, + {"november", "11"}, + {"dezember", "12"} + }; + string[,] weekdays = { + {"montag", "1"}, + {"dienstag", "2"}, + {"mittwoch", "3"}, + {"donnerstag", "4"}, + {"freitag", "5"}, + {"samstag", "6"}, + {"sonntag", "7"} + }; + + string months_regex; + string weekdays_regex; + + struct String_event { bool matched; string matched_string; int pos; int length; Array p; } + + delegate void transcribe_analysis (String_event data); + + public ParserDe (DateTime _simulated_dt = new DateTime.now_local ()) { + this.simulated_dt = _simulated_dt; + + this.source = ""; + this.remaining_source = ""; + + this.months_regex = ""; + for (int i = 0; i < 12; i++) + this.months_regex += months[i, 0] + "|"; + this.months_regex = this.months_regex[0:-1]; + + this.weekdays_regex = ""; + for (int i = 0; i < 7; i++) + this.weekdays_regex += weekdays[i, 0] + "|"; + this.weekdays_regex = this.weekdays_regex[0:-1]; + } + + + int get_number_of_month (string entry) { + for (int i = 0; i < 12; i++) { + if (entry.down () == months[i, 0]) + return int.parse (months[i, 1]); + } + return -1; + } + + int get_number_of_weekday (string entry) { + for (int i = 0; i < 12; i++) { + if (entry.down () == weekdays[i, 0]) + return int.parse (weekdays[i, 1]); + } + return -1; + } + + + // finds regex "pattern" in string source + String_event complete_string (string pattern) { + Regex regex; + MatchInfo match_info; + try { + regex = new Regex (pattern, RegexCompileFlags.CASELESS); + var is_matched = regex.match (this.remaining_source, 0, out match_info); + if (!is_matched) + return String_event () { matched = false }; + } catch { + return String_event () { matched = false }; + } + + var matched_string = match_info.fetch (0); + var pos = this.remaining_source.index_of (matched_string); + var length = matched_string.length; + + var p = new Array (); + + while (match_info.matches ()) { + for (var i = 0; i < 4; i++) + p.append_val (match_info.fetch_named (@"p$(i + 1)")); + + try { + match_info.next (); + } catch (GLib.RegexError exc) { + // TODO + } + } + + return String_event () { matched = true, pos = pos, length = length, matched_string = matched_string, p = p }; + } + + void analyze_pattern (string pattern, transcribe_analysis del) { + String_event data = complete_string ("\\b" + pattern + "\\b"); + if (data.matched) { + this.remaining_source = this.remaining_source.splice (data.pos, data.pos + data.length); + del (data); + } + } + + + public ParsedEvent parse_source (string _source) { + this.source = _source; + this.remaining_source = this.source; + + + var event = new ParsedEvent (); + event.from = this.simulated_dt.add_hours (1); + event.from_set_minute (0); + event.from_set_second (0); + event.set_length_to_hours (1); + + // --- Date --- + + analyze_pattern ("vorgestern", (data) => { + event.from = event.from.add_days (-2); + event.set_one_entire_day (); + }); + + analyze_pattern ("gestern", (data) => { + event.from = event.from.add_days (-1); + event.set_one_entire_day (); + }); + + analyze_pattern ("(ab )?morgen", (data) => { + event.from = event.from.add_days(1); + event.set_one_entire_day(); + }); + + analyze_pattern ("(ab )?übermorgen", (data) => { + event.from = event.from.add_days (2); + event.set_one_entire_day (); + }); + + analyze_pattern ("(den ganzen tag|ganztägig)", (data) => { + event.set_one_entire_day (); + }); + + analyze_pattern ("vor (?\\d+) tagen", (data) => { + int days = int.parse ( data.p.index(0) ); + event.from = event.from.add_days (-days); + event.set_one_entire_day (); + }); + + analyze_pattern ("in (?\\d+) tagen", (data) => { + int days = int.parse (data.p.index(0)); + event.from = event.from.add_days (days); + event.set_one_entire_day(); + }); + + analyze_pattern (@"diesen (?$weekdays_regex)", (data) => { + int weekday = get_number_of_weekday (data.p.index (0)); + int add_days = (weekday - this.simulated_dt.get_day_of_week () + 7 ) % 7; + event.from = event.from.add_days (add_days); + + event.set_one_entire_day (); + }); + + analyze_pattern (@"nächsten (?$weekdays_regex)", (data) => { + int weekday = get_number_of_weekday (data.p.index (0)); + int add_days = (weekday - this.simulated_dt.get_day_of_week () + 7 ) % 7; + event.from = event.from.add_days (add_days); + + event.set_one_entire_day (); + }); + + analyze_pattern (@"übernächsten (?$weekdays_regex)", (data) => { + int weekday = get_number_of_weekday (data.p.index(0)); + int add_days = (weekday - this.simulated_dt.get_day_of_week () + 7 ) % 7; + event.from = event.from.add_weeks (1); + event.from = event.from.add_days (add_days); + + event.set_one_entire_day (); + }); + + analyze_pattern ("am (?\\d+).(?\\d+)(.(?\\d+))?", (data) => { + int day = int.parse (data.p.index (0)); + int month = int.parse (data.p.index(1)); + + event.from_set_day (day); + event.set_one_entire_day (); + + event.from_set_month (month); + event.to_set_month (month); + + if (data.p.index (2) != null ) { + int year = int.parse (data.p.index (2)); + event.from_set_year (year); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + } + + event.if_elapsed_delay_to_next_month (this.simulated_dt); + }); + + analyze_pattern (@"vom (?\\d+). bis (?\\d+). ((?$months_regex))?", (data) => { + int day_1 = int.parse (data.p.index (0)); + int day_2 = int.parse (data.p.index (1)); + + event.from_set_day (day_1); + event.to_set_day (day_2); + event.set_all_day (); + + if (data.p.index (2) != null) { + int month = get_number_of_month (data.p.index (2)); + event.from_set_month (month); + event.to_set_month (month); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + } + + event.if_elapsed_delay_to_next_month (this.simulated_dt); + }); + + analyze_pattern (@"am (?\\d+)(.)?( (?$months_regex))?", (data) => { + int day = int.parse (data.p.index (0)); + int month = get_number_of_month (data.p.index (1)); + + event.from_set_day (day); + event.from_set_month (month); + event.set_one_entire_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + analyze_pattern ("heiligabend", (data) => { + event.from_set_month (12); + event.from_set_day (24); + event.set_one_entire_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + // --- Time --- + + analyze_pattern ("früh", (data) => { + event.from_set_hour (9); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("vormittags", (data) => { + event.from_set_hour (11); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("mittag(s?)", (data) => { + event.from_set_hour (12); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("nachmittags", (data) => { + event.from_set_hour (15); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("abends", (data) => { + event.from_set_hour (18); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("spät", (data) => { + event.from_set_hour (19); + event.set_length_to_hours (3); + event.all_day = false; + }); + + analyze_pattern ("(um|ab) (?\\d+)(:(?\\d+))?( (uhr|h))?", (data) => { + int hour = int.parse (data.p.index (0)); + event.from_set_hour (hour); + + if (data.p.index (1) != null) { + int minute_1 = int.parse (data.p.index (1)); + event.from_set_minute (minute_1); + } + + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("von (?\\d+)(:(?\\d+))? bis (?\\d+)(:(?\\d+))?( uhr)?", (data) => { + int hour_1 = int.parse (data.p.index (0)); + int hour_2 = int.parse (data.p.index (1)); + + event.from_set_hour (hour_1); + event.to_set_hour (hour_2); + + if (data.p.index (2) != null) { + int minute_1 = int.parse (data.p.index (2)); + event.from_set_minute (minute_1); + } + if (data.p.index (3) != null) { + int minute_2 = int.parse (data.p.index (3)); + event.to_set_minute (minute_2); + } + event.all_day = false; + }); + + analyze_pattern ("(?\\d+)(:(?\\d+))? (uhr|h)", (data) => { + int hour = int.parse (data.p.index (0)); + event.from_set_hour (hour); + + if (data.p.index(1) != null) { + int minute_1 = int.parse (data.p.index (1)); + event.from_set_minute (minute_1); + } + + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("für (?\\d+)(\\s?min| Minuten)", (data) => { + int minutes = int.parse (data.p.index (0)); + event.set_length_to_minutes (minutes); + }); + + analyze_pattern ("für (?\\d+)(\\s?h| Stunden)", (data) => { + int hours = int.parse (data.p.index (0)); + event.set_length_to_hours (hours); + }); + + analyze_pattern ("für (?\\d+)(\\s?d| Tage)", (data) => { + int days = int.parse (data.p.index (0)); + event.set_length_to_days (days); + }); + + analyze_pattern ("für (?\\d+) Wochen", (data) => { + int weeks = int.parse (data.p.index (0)); + event.set_length_to_weeks (weeks); + }); + + // --- Repetition --- + + // --- Persons --- + + // --- Location ---- + analyze_pattern ("(im|in dem) (?(\\w\\s?)+)", (data) => { + event.location = data.p.index (0); + }); + + analyze_pattern ("in( der)? (?[a-z]+)", (data) => { + event.location = data.p.index (0); + }); + + // --- Name --- + + event.title = this.remaining_source.strip (); + + return event; + } + + public string get_language () { + return "de"; + } +} + +} diff -Nru maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserEn.vala maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserEn.vala --- maya-calendar-0.3.1.1+r843+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserEn.vala 1970-01-01 00:00:00.000000000 +0000 +++ maya-calendar-0.3.1.1+r845+pkg70~daily~ubuntu16.04.1/src/EventParser/Parsers/ParserEn.vala 2015-11-30 05:17:14.000000000 +0000 @@ -0,0 +1,579 @@ +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- +/*** + BEGIN LICENSE + + Copyright (C) 2015 Mario Guerriero + pantor + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License version 3, as published + by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranties of + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see + + END LICENSE +***/ + +namespace Maya.Services { + +public class ParserEn : GLib.Object, EventParser { + + public DateTime simulated_dt; + + public string source; + private string remaining_source; + + + string[,] months = { + {"january", "1"}, + {"february", "2"}, + {"march", "3"}, + {"april", "4"}, + {"may", "5"}, + {"june", "6"}, + {"july", "7"}, + {"august", "8"}, + {"september", "9"}, + {"october", "10"}, + {"november", "11"}, + {"december", "12"} + }; + string[,] weekdays = { + {"monday", "1"}, + {"tuesday", "2"}, + {"wednesday", "3"}, + {"thursday", "4"}, + {"thu", "4"}, + {"friday", "5"}, + {"saturday", "6"}, + {"sunday", "7"} + }; + string[,] number_words = { + {"one", "1"}, + {"two", "2"}, + {"three", "3"}, + {"four", "4"}, + {"five", "5"}, + {"six", "6"}, + {"seven", "7"}, + {"eight", "8"}, + {"nine", "9"}, + {"ten", "10"}, + {"eleven", "11"}, + {"twelve", "12"} + }; + + string months_regex; + string weekdays_regex; + string number_words_regex; + + + + struct String_event { bool matched; string matched_string; int pos; int length; Array p; } + + delegate void transcribe_analysis (String_event data); + + + + public ParserEn (DateTime _simulated_dt = new DateTime.now_local ()) { + this.simulated_dt = _simulated_dt; + + this.source = ""; + this.remaining_source = ""; + + this.months_regex = "("; + for (int i = 0; i < 12; i++) + this.months_regex += months[i, 0] + "|"; + this.months_regex = this.months_regex[0:-1] + ")"; + + this.weekdays_regex = "("; + for (int i = 0; i < 7; i++) + this.weekdays_regex += weekdays[i, 0] + "|"; + this.weekdays_regex = this.weekdays_regex[0:-1] + ")"; + + this.number_words_regex = "("; + for (int i = 0; i < 7; i++) + this.number_words_regex += number_words[i, 0] + "|"; + this.number_words_regex = this.number_words_regex[0:-1] + ")"; + } + + + int get_number_of_month (string entry) { + for (int i = 0; i < 12; i++) { + if (entry.down () == months[i, 0]) + return int.parse (months[i, 1]); + } + return -1; + } + + int get_number_of_weekday (string entry) { + for (int i = 0; i < 12; i++) { + if (entry.down () == weekdays[i, 0]) + return int.parse (weekdays[i, 1]); + } + return -1; + } + + /*int get_number_of_word (string entry) { + for (int i = 0; i < 12; i++) { + if (entry.down () == number_words[i, 0]) + return int.parse (number_words[i, 1]); + } + return -1; + }*/ + + // finds regex "pattern" in string source + String_event complete_string (string pattern) { + Regex regex; + MatchInfo match_info; + try { + regex = new Regex (pattern, RegexCompileFlags.CASELESS); + var is_matched = regex.match (this.remaining_source, 0, out match_info); + if (!is_matched) + return String_event () { matched = false }; + } catch { + return String_event () { matched = false }; + } + + var matched_string = match_info.fetch (0); + var pos = this.remaining_source.index_of (matched_string); + var length = matched_string.length; + + var p = new Array (); + + while (match_info.matches ()) { + for (var i = 0; i < 6; i++) + p.append_val (match_info.fetch_named (@"p$(i + 1)")); + + try { + match_info.next (); + } catch (GLib.RegexError exc) { + // TODO + } + } + + return String_event () { matched = true, pos = pos, length = length, matched_string = matched_string, p = p }; + } + + void analyze_pattern (string pattern, transcribe_analysis del, bool delete = true) { + String_event data = complete_string ("\\b" + pattern + "\\b"); + if (data.matched) { + if (delete) + this.remaining_source = this.remaining_source.splice (data.pos, data.pos + data.length); + + del (data); + } + } + + + public ParsedEvent parse_source (string _source) { + this.source = _source; + this.remaining_source = this.source; + + + var event = new ParsedEvent (); + event.from = this.simulated_dt.add_hours (1); + event.from_set_minute (0); + event.from_set_second (0); + event.set_length_to_hours (1); + + // --- Date --- + + analyze_pattern ("two days ago", (data) => { + event.from = event.from.add_days (-2); + event.set_one_entire_day (); + }); + + analyze_pattern ("yesterday", (data) => { + event.from = event.from.add_days (-1); + event.set_one_entire_day (); + }); + + analyze_pattern ("today", (data) => { + event.set_one_entire_day (); + }); + + analyze_pattern ("tomorrow", (data) => { + event.from = event.from.add_days (1); + event.set_one_entire_day (); + }); + + analyze_pattern ("this weekend", (data) => { + int add_days = (6 - this.simulated_dt.get_day_of_week () + 7) % 7; + event.from = event.from.add_days (add_days); + event.to = event.from.add_days (1); + event.set_all_day (); + }); + + analyze_pattern ("all day", (data) => { + event.set_one_entire_day (); + }); + + analyze_pattern ("the whole day", (data) => { + event.set_one_entire_day (); + }); + + analyze_pattern ("next week", (data) => { + event.from = event.from.add_days (7); + event.set_all_day (); + }); + + analyze_pattern ("next month", (data) => { + event.from = event.from.add_months (1); + event.set_all_day (); + }); + + analyze_pattern ("(?\\d+) days ago", (data) => { + int days = int.parse(data.p.index (0)); + event.from = event.from.add_days (-days); + event.set_one_entire_day (); + }); + + analyze_pattern ("in (?\\d+) days", (data) => { + int days = int.parse (data.p.index (0)); + event.from = event.from.add_days (days); + event.set_one_entire_day (); + }); + + analyze_pattern ("in (?\\d+) weeks", (data) => { + int weeks = int.parse (data.p.index (0)); + event.from = event.from.add_weeks (weeks); + event.set_one_entire_day (); + }); + + analyze_pattern (@"(next|on) (?$weekdays_regex)", (data) => { + int weekday = get_number_of_weekday (data.p.index (0)); + int add_days = (weekday - this.simulated_dt.get_day_of_week () + 7) % 7; + event.from = event.from.add_days (add_days); + + event.set_one_entire_day (); + }); + + analyze_pattern (@"(this )?(?$weekdays_regex)( to (?$weekdays_regex))?", (data) => { + int weekday_1 = get_number_of_weekday (data.p.index (0)); + int add_days_1 = (weekday_1 - this.simulated_dt.get_day_of_week () + 7) % 7; + + event.from = event.from.add_days (add_days_1); + event.set_all_day (); + + if (data.p.index (1) != null) { + int weekday_2 = get_number_of_weekday (data.p.index (1)); + int add_days_2 = (weekday_2 - weekday_1 + 7) % 7; + + event.to = event.from.add_days (add_days_2); + } + }); + + analyze_pattern (@"on ((?\\d{2,4})/)?(?\\d{1,2})/(?\\d{1,2})(st|nd|rd|th)?", (data) => { + int day = int.parse (data.p.index (2)); + int month = int.parse (data.p.index (1)); + + event.from_set_day (day); + event.from_set_month (month); + event.set_one_entire_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + + if (data.p.index (0) != null) { + int year = int.parse (data.p.index (0)); + event.from_set_year (year); + } + }); + + analyze_pattern (@"on (?\\d{0,1})(st|nd|rd|th)? (?$months_regex)( (?\\d{2,4}))?", (data) => { + int day = int.parse (data.p.index (0)); + int month = get_number_of_month (data.p.index (1)); + + event.from_set_day (day); + event.from_set_month (month); + event.set_one_entire_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + + if (data.p.index (2) != null) { + int year = int.parse (data.p.index (2)); + event.from_set_year (year); + } + }); + + analyze_pattern (@"on (?$months_regex)(,)? (?\\d{1,2})(st|nd|rd|th)?( (?\\d{2,4}))?", (data) => { + int day = int.parse (data.p.index (1)); + int month = get_number_of_month (data.p.index (0)); + + event.from_set_day (day); + event.from_set_month (month); + event.set_one_entire_day (); + + if (data.p.index (2) != null) { + int year = int.parse (data.p.index (2)); + event.from_set_year (year); + } + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + analyze_pattern (@"from (?\\d{1,2})(.)? to (?\\d{1,2}). ((?$months_regex))?", (data) => { + int day_1 = int.parse (data.p.index (0)); + int day_2 = int.parse (data.p.index (1)); + + event.from_set_day (day_1); + event.to_set_day (day_2); + event.set_all_day (); + + if (data.p.index (2) != null) { + int month = get_number_of_month (data.p.index (2)); + event.from_set_month (month); + event.to_set_month (month); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + } + + event.if_elapsed_delay_to_next_month (this.simulated_dt); + }); + + analyze_pattern (@"from (?\\d{1,2})/(?\\d{1,2}) - ((?\\d{1,2})/)?(?\\d{1,2})", (data) => { + int day_1 = int.parse (data.p.index (1)); + int day_2 = int.parse (data.p.index (3)); + int month_1 = int.parse (data.p.index (0)); + int month_2 = int.parse (data.p.index (2)); + + if (month_2 == 0) + month_2 = month_1; + + event.from_set_day (day_1); + event.to_set_day( day_2); + event.from_set_month (month_1); + event.to_set_month (month_2); + event.set_all_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + analyze_pattern (@"from (?$months_regex) (?\\d{1,2})(st|nd|rd|th)? - (?\\d{1,2})(st|nd|rd|th)?", (data) => { + int day_1 = int.parse (data.p.index (1)); + int day_2 = int.parse (data.p.index (2)); + int month_1 = get_number_of_month (data.p.index (0)); + + event.from_set_day (day_1); + event.to_set_day (day_2); + event.from_set_month (month_1); + event.to_set_month (month_1); + + event.set_all_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + analyze_pattern ("in a month", (data) => { + event.from = event.from.add_months (1); + event.set_one_entire_day (); + }); + + analyze_pattern ("christmas eve", (data) => { + event.from_set_month (12); + event.from_set_day (24); + event.set_one_entire_day (); + + event.if_elapsed_delay_to_next_year (this.simulated_dt); + }); + + + // --- Time --- + + analyze_pattern ("breakfast", (data) => { + event.from_set_hour (8); + event.set_length_to_hours (1); + event.all_day = false; + }, false); + + analyze_pattern ("lunch", (data) => { + event.from_set_hour (13); + event.set_length_to_hours (1); + event.all_day = false; + }, false); + + analyze_pattern ("dinner", (data) => { + event.from_set_hour (19); + event.set_length_to_hours (1); + event.all_day = false; + }, false); + + analyze_pattern ("early", (data) => { + event.from_set_hour (9); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("(this )?morning", (data) => { + event.from_set_hour (11); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("(at |this )?noon", (data) => { + event.from_set_hour (12); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("(this )?afternoon", (data) => { + event.from_set_hour (15); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("(this )?evening", (data) => { + event.from_set_hour (18); + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("late", (data) => { + event.from_set_hour (19); + event.set_length_to_hours (3); + event.all_day = false; + }); + + analyze_pattern ("(?\\d{1,2})?(?(am|pm|p))?(to |-| - )(?\\d{1,2})?(?(am|pm|p))?", (data) => { + int hour_1 = int.parse (data.p.index (0)); + int hour_2 = int.parse (data.p.index (2)); + + string half_1 = ""; + if (data.p.index (1) != null) + half_1 = data.p.index (1); + + string half_2 = ""; + if (data.p.index (3) != null) + half_2 = data.p.index (3); + + event.from_set_hour (hour_1, half_1); + event.to_set_hour (hour_2, half_2); + + event.all_day = false; + }); + + analyze_pattern ("(at |@ ?)(?\\d{1,2})(:(?\\d{1,2}))?(?(am|pm|p))?", (data) => { + int hour = int.parse (data.p.index(0)); + + if (data.p.index (1) != null) { + int minute_1 = int.parse(data.p.index (1)); + event.from_set_minute (minute_1); + } + + string half = ""; + if (data.p.index (2) != null) + half = data.p.index (2); + + event.from_set_hour (hour, half); + + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("(at |@)(?\\d{4})", (data) => { + int hour = int.parse (data.p.index (0)); + + if (data.p.index (1) != null) { + int minute_1 = int.parse (data.p.index (1)); + event.from_set_minute (minute_1); + } + + string half = ""; + if (data.p.index (2) != null) + half = data.p.index (2); + event.from_set_hour (hour, half); + + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("from (?\\d{1,2})(:(?\\d{1,2}))?(?(am|pm|p)?) to (?\\d{1,2})(:(?\\d{1,2}))?(?(am|pm|p)?)", (data) => { + int hour_1 = int.parse (data.p.index (0)); + int hour_2 = int.parse (data.p.index (1)); + + string half_1 = ""; + if (data.p.index (4) != null) + half_1 = data.p.index (4); + event.from_set_hour (hour_1, half_1); + + string half_2 = ""; + if (data.p.index (5) != null) + half_2 = data.p.index (5); + event.to_set_hour (hour_2, half_2); + + if (data.p.index (2) != null) { + int minute_1 = int.parse (data.p.index (2)); + event.from_set_minute (minute_1); + } + if (data.p.index (3) != null) { + int minute_2 = int.parse (data.p.index (3)); + event.to_set_minute (minute_2); + } + event.all_day = false; + }); + + analyze_pattern ("(?\\d{1,2})(:(?\\d{1,2}))? (o'clock|h)", (data) => { + int hour = int.parse (data.p.index (0)); + event.from_set_hour (hour); + + if (data.p.index (1) != null) { + int minute_1 = int.parse (data.p.index (1)); + event.from_set_minute (minute_1); + } + + event.set_length_to_hours (1); + event.all_day = false; + }); + + analyze_pattern ("for (?\\d+)(\\s?min| minutes)", (data) => { + int minutes = int.parse (data.p.index (0)); + event.set_length_to_minutes (minutes); + }); + + analyze_pattern ("for (?\\d+)(\\s?h| hours)", (data) => { + int hours = int.parse (data.p.index(0)); + event.set_length_to_hours (hours); + }); + + analyze_pattern ("for (?\\d+)(\\s?d| days)", (data) => { + int days = int.parse (data.p.index (0)); + event.set_length_to_days (days); + }); + + analyze_pattern ("for (?\\d+) weeks", (data) => { + int weeks = int.parse (data.p.index (0)); + event.set_length_to_weeks(weeks); + }); + + // --- Repetition --- + + // --- Persons --- + analyze_pattern ("(with)( the)? (?(\\w\\s?)+)", (data) => { + for (int i = 0; i < data.p.length ; i++) + event.participants += data.p.index (i); + }); + + // --- Location ---- + analyze_pattern ("(at|in)(the)? (?(\\w\\s?)+)", (data) => { + event.location = data.p.index (0); + }); + + // --- Name --- + event.title = this.remaining_source.strip (); + // event.title = event.title.strip(); + // Strip ,.: from title + + return event; + } + + public string get_language () { + return EventParserHandler.FALLBACK_LANG; + } +} + +}