Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/date_parity/core_ext/date.rb

Class Method Summary collapse

Class Method Details

._parse_with_date_parity_format(string, comp = false) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/date_parity/core_ext/date.rb', line 10

def _parse_with_date_parity_format(string, comp=false)
  return _parse_without_date_parity_format(string, comp) if string.blank? or Date.format.blank?
  # normalize date by first respecting custom date_parity Date.format, 
  # then formatting back to iso/db string for normal _parse call.
  _parse_without_date_parity_format(Date.strptime(string, Date.format).to_s(:db), comp)
rescue
  _parse_without_date_parity_format(string, comp)
end

.formatObject



3
4
5
# File 'lib/date_parity/core_ext/date.rb', line 3

def format
  Thread.current[:date_format] || Date::DATE_FORMATS[:db]  || "%Y-%m-%d"
end

.format=(format) ⇒ Object



6
7
8
# File 'lib/date_parity/core_ext/date.rb', line 6

def format=(format)
  Thread.current[:date_format] = format
end