|
|
|
2 WAITING_FOR_KEYS = Hash.new(:other).merge(0 => :zero, 1 => :one)
|
|
3 TO_BE_DEBATED_KEYS = Hash.new(:other).merge(0 => :today, 1 => :tomorrow)
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
5 def short_date_format(date_time)
|
|
6 date_time && date_time.strftime("%-d %B %Y")
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
9 def short_date_time_format(date_time)
|
|
10 date_time && date_time.strftime("%H:%M%P on %-d %B %Y")
|
|
|
|
|
- BooleanParameter - has boolean parameter 'seconds' » reek
- ControlParameter - is controlled by argument 'seconds' » reek
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 2 » saikuro
|
13 def date_time_format(date_time, seconds: false)
|
|
|
|
15 date_time && date_time.strftime("%d-%m-%Y %H:%M:%S")
|
|
|
|
17 date_time && date_time.strftime("%d-%m-%Y %H:%M")
|
|
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
21 def date_format(date_time)
|
|
22 date_time && date_time.strftime("%d/%m/%Y")
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
25 def date_format_admin(date_time)
|
|
26 date_time && date_time.strftime("%d-%m-%Y")
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
29 def local_date_time_format(date_time)
|
|
30 date_time && date_time.in_time_zone.strftime("%d/%m/%Y %H:%M")
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
33 def last_updated_at_time(date_time)
|
|
34 date_time && date_time.in_time_zone.strftime("%H:%M %Z")
|
|
|
|
|
|
37 def waiting_for_in_words(date, now = Time.current)
|
|
38 return unless date.present?
|
|
|
|
40 scope = :"petitions.waiting_for_in_words"
|
|
41 days = ((now.end_of_day - date.end_of_day) / 86400.0).round
|
|
42 key = WAITING_FOR_KEYS[days]
|
|
|
|
44 t(key, scope: scope, formatted_count: number_with_delimiter(days))
|
|
|
|
|
- ManualDispatch - manually dispatches method call » reek
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 3 » saikuro
|
47 def api_date_format(date_time)
|
|
|
|
49 if date_time.respond_to?(:getutc)
|
|
50 date_time.getutc.iso8601(3)
|
|
|
|
52 date_time.strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
57 def scheduled_for_debate_in_words(date, today = Date.current)
|
|
58 scope = :"petitions.scheduled_for_debate_in_words"
|
|
59 days = (date - today).to_i
|
|
60 key = TO_BE_DEBATED_KEYS[days]
|
|
|
|
62 t(key, scope: scope, formatted_date: short_date_format(date))
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
65 def christmas_period?(today = Date.current)
|
|
66 Holiday.christmas?(today)
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
69 def easter_period?(today = Date.current)
|
|
70 Holiday.easter?(today)
|
|
|
|
|