Module Tools::Calendar::InstanceMethods
In: app/models/tools/calendar.rb

Calendar specific methods

Methods

day   days   first_day   has_hour?   month   one_day?   sort_position   year  

Public Instance methods

Devuelve el día de la fecha de inicio del evento.

[Source]

    # File app/models/tools/calendar.rb, line 28
28:     def day
29:       @day || self.starts_at.day
30:     end

Devuelve una lista con los día del evento para el mes y el año indicados. Por ejemplo, para un evento que empieza el 30 de enero y acaba el 2 de febrero esta función devolverá [30, 31] cuando for_moth = 1 y [1,2] cuando for_month=2

[Source]

    # File app/models/tools/calendar.rb, line 61
61:     def days(for_month=nil, for_year = nil)
62:       days_list = []
63:       if self.one_day?
64:         days_list = [self.day]
65:       else
66:         for_month ||= self.starts_at.month
67:         for_year  ||= self.starts_at.year
68: 
69:         check_date = Date.parse("#{for_year}-#{for_month}-1").at_beginning_of_month
70: 
71:         if (self.starts_at > check_date.end_of_month) || (self.ends_at < check_date)
72:           days_list = []
73:         else
74:           # logger.debug "............................. for_month = #{for_month}, for_year = #{for_year}"
75:           # logger.debug "............................. ends_at = #{self.ends_at}"
76:           first_day =  (self.starts_at >= check_date) ? self.starts_at.day : 1
77:           last_day =  (self.ends_at <= check_date.at_end_of_month) ?  self.ends_at.day : check_date.end_of_month.day
78: 
79:           # logger.debug "....................... first_day = #{first_day}, last_day = #{last_day}"
80:           days_list = (first_day..last_day).to_a
81:         end
82:       end
83:       days_list
84:     end

Devuelve del primer día del evento para el mes y el año indicados. Por ejemplo, para un evento que empieza el 30 de enero y acaba el 2 de febrero esta función devolverá 30 cuando for_moth = 1 y 1 cuando for_month=2.

[Source]

    # File app/models/tools/calendar.rb, line 43
43:     def first_day(for_month, for_year)
44:       for_date = Date.parse("#{for_year}-#{for_month}-1").at_beginning_of_month
45:       if (self.starts_at > for_date.end_of_month) || (self.ends_at < for_date)
46:         the_day = nil
47:       else
48:         if self.starts_at > for_date
49:           the_day = self.starts_at.day
50:         else
51:           the_day = 1
52:         end
53:       end
54:       the_day
55:     end

Indica si el evento tiene especificada la hora de inicio.

[Source]

    # File app/models/tools/calendar.rb, line 13
13:     def has_hour?
14:       self.starts_at.strftime('%H%M') != "0000"
15:     end

Devuelve el mes de la fecha de inicio del evento.

[Source]

    # File app/models/tools/calendar.rb, line 23
23:     def month
24:       @month || self.starts_at.month
25:     end

Indica si el evento es de un día o no.

[Source]

    # File app/models/tools/calendar.rb, line 8
 8:     def one_day?
 9:       self.starts_at.to_date.to_s.eql?(self.ends_at.to_date.to_s)
10:     end

Valor que se usa para ordenar los eventos dentro de un día. Primero salen los eventos del día, ordendos por hora y al final los eventos que abarcan más de un día.

[Source]

    # File app/models/tools/calendar.rb, line 35
35:     def sort_position
36:       pos = self.one_day? ? 0 : 1000
37:       pos += self.starts_at.hour
38:     end

Devuelve el año de la fecha de inicio del evento.

[Source]

    # File app/models/tools/calendar.rb, line 18
18:     def year
19:       @year || self.starts_at.year
20:     end

[Validate]