Class: Date

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(string) ⇒ Object



17
18
19
20
# File 'lib/core_ext/date.rb', line 17

def self.json_create string
  return nil if string.nil?
  Date.parse(string)
end

Instance Method Details

#to_json(*a) ⇒ Object



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

def to_json(*a)
  %("#{to_s(:json)}")
end

#to_s_with_json(*args) ⇒ Object Also known as: to_s



6
7
8
9
10
11
12
# File 'lib/core_ext/date.rb', line 6

def to_s_with_json(*args)
  if args[0] == :json
    strftime("%Y/%m/%d")
  else
    to_s_without_json *args
  end
end