summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'helpers')
-rw-r--r--helpers/calendar_helpers.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/helpers/calendar_helpers.rb b/helpers/calendar_helpers.rb
new file mode 100644
index 0000000..daa4625
--- /dev/null
+++ b/helpers/calendar_helpers.rb
@@ -0,0 +1,39 @@
+require 'date'
+
+module CalendarHelpers
+
+ class Event
+
+ # TODO i18n weekdays, group dates
+
+ FORMATS = {
+ time_only: "%H:%M",
+ date_only: "%a. %d.%m"
+ }
+
+ def initialize(args={})
+ @summary = args.fetch("summary")
+ @start_time = DateTime.parse(args.fetch("start"))
+ @end_time = DateTime.parse(args.fetch("end"))
+ end
+
+ def summary
+ @summary
+ end
+
+ def start_time
+ @start_time.strftime(FORMATS[:time_only])
+ end
+
+ def end_time
+ @end_time.strftime(FORMATS[:time_only])
+ end
+
+ def date
+ @start_time.strftime(FORMATS[:date_only])
+ end
+
+ end
+
+
+end