Class: Tareek::Dates
- Inherits:
-
Object
- Object
- Tareek::Dates
- Defined in:
- lib/tareek.rb
Class Method Summary collapse
- .convert_to_date(date) ⇒ Object
- .date_of_next(day) ⇒ Object
- .day_middle_of_next_month_date(year, month) ⇒ Object
- .day_middle_of_past_month_date(year, month) ⇒ Object
- .day_on(date) ⇒ Object
- .get_middle_of_next_month_date(year, month) ⇒ Object
- .get_middle_of_past_month_date(year, month) ⇒ Object
- .humanize_with_day(date) ⇒ Object
- .humanize_with_day_and_full_year(date) ⇒ Object
- .humanize_without_day(date) ⇒ Object
- .omniture_format_with_time(date) ⇒ Object
- .parse_date(month, year) ⇒ Object
- .time_at_day(date) ⇒ Object
Class Method Details
.convert_to_date(date) ⇒ Object
63 64 65 |
# File 'lib/tareek.rb', line 63 def convert_to_date(date) (date.kind_of? Date) ? date : Date.parse(date) end |
.date_of_next(day) ⇒ Object
33 34 35 36 37 |
# File 'lib/tareek.rb', line 33 def date_of_next(day) date = convert_to_date(day) delta = date > Date.today ? 0 : 7 date + delta end |
.day_middle_of_next_month_date(year, month) ⇒ Object
21 22 23 |
# File 'lib/tareek.rb', line 21 def day_middle_of_next_month_date(year, month) day_on(get_middle_of_next_month_date(year, month)) end |
.day_middle_of_past_month_date(year, month) ⇒ Object
25 26 27 |
# File 'lib/tareek.rb', line 25 def day_middle_of_past_month_date(year, month) day_on(get_middle_of_past_month_date(year, month)) end |
.day_on(date) ⇒ Object
39 40 41 |
# File 'lib/tareek.rb', line 39 def day_on(date) convert_to_date(date).strftime("%A") end |
.get_middle_of_next_month_date(year, month) ⇒ Object
13 14 15 |
# File 'lib/tareek.rb', line 13 def get_middle_of_next_month_date(year, month) (parse_date(month,year) + 45 * 24 * 60 * 60).to_date end |
.get_middle_of_past_month_date(year, month) ⇒ Object
17 18 19 |
# File 'lib/tareek.rb', line 17 def get_middle_of_past_month_date(year, month) (parse_date(month,year) - 15 * 24 * 60 * 60).to_date end |
.humanize_with_day(date) ⇒ Object
47 48 49 |
# File 'lib/tareek.rb', line 47 def humanize_with_day(date) convert_to_date(date).strftime('%d-%b-%y') end |
.humanize_with_day_and_full_year(date) ⇒ Object
51 52 53 |
# File 'lib/tareek.rb', line 51 def humanize_with_day_and_full_year(date) convert_to_date(date).strftime('%d %b %Y') end |
.humanize_without_day(date) ⇒ Object
43 44 45 |
# File 'lib/tareek.rb', line 43 def humanize_without_day(date) convert_to_date(date).strftime('%b %y') end |
.omniture_format_with_time(date) ⇒ Object
59 60 61 |
# File 'lib/tareek.rb', line 59 def omniture_format_with_time(date) convert_to_date(date).strftime('%m/%d/%Y %I:%M:%S %p') end |
.parse_date(month, year) ⇒ Object
29 30 31 |
# File 'lib/tareek.rb', line 29 def parse_date(month,year) Time.parse("1-#{month}-#{year} 0:1 UTC") end |
.time_at_day(date) ⇒ Object
55 56 57 |
# File 'lib/tareek.rb', line 55 def time_at_day(date) convert_to_date(date).strftime('%I:%M %p') end |