Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/date_parity/core_ext/date.rb
Class Method Summary collapse
- ._parse_with_date_parity_format(string, comp = false) ⇒ Object
- .format ⇒ Object
- .format=(format) ⇒ Object
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 |
.format ⇒ Object
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 |