summaryrefslogtreecommitdiff
path: root/helpers/calendar_helpers.rb
blob: daa4625c96ec762bc8747a9b07279cc476eb8224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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