Module: Ventana
- Extended by:
- Ventana
- Included in:
- Ventana
- Defined in:
- lib/ventana/i18n.rb,
lib/ventana/method.rb,
lib/ventana/version.rb
Constant Summary collapse
- SCOPE =
:ventana
- VERSION =
"0.9.2"
Instance Method Summary collapse
- #date_format(from, to) ⇒ Object
- #show_days?(from, to) ⇒ Boolean
- #show_time?(from, to) ⇒ Boolean
- #time_format(date) ⇒ Object
Instance Method Details
#date_format(from, to) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ventana/method.rb', line 6 def date_format(from,to) format = if to.year > from.year # must show year difference "full_dates" elsif to.month > from.month # must show month difference "single_year" elsif to.day > from.day # within the same month "single_month" else # within the same day "single_day" end if Ventana.show_days?(from,to) format << "_with_days" else format << "_without_days" end unless format == "single_day" format end |
#show_days?(from, to) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ventana/method.rb', line 34 def show_days?(from,to) from.day != 1 || to.day != case to.month when 1,3,5,7,8,10,12 then 31 when 4,6,9,11 then 30 else if (to.year % 4) == 0 29 else 28 end end end |
#show_time?(from, to) ⇒ Boolean
51 52 53 54 55 56 57 58 |
# File 'lib/ventana/method.rb', line 51 def show_time?(from,to) from.hour != 0 || from.minutes != 0 || from.seconds != 0 || to.hour != 12 || to.minutes != 0 || to.seconds != 0 end |
#time_format(date) ⇒ Object
30 31 32 |
# File 'lib/ventana/method.rb', line 30 def time_format(from,to) end |