Module: Safrano::CoreIncl::Date::Format

Defined in:
lib/core_ext/Date/format.rb

Instance Method Summary collapse

Instance Method Details

#to_edm_jsonObject

www.odata.org/documentation/odata-version-2-0/json-format/ Edm.DateTime “/Date(<ticks>[”+“ | ”-“ <offset>)/”

<ticks> = number of milliseconds since midnight Jan 1, 1970
<offset> = number of minutes to add or subtract

stackoverflow.com/questions/10286204/what-is-the-right-json-date-format/10286228#10286228



40
41
42
43
44
45
46
47
48
# File 'lib/core_ext/Date/format.rb', line 40

def to_edm_json
  # no offset
  # --> %Q milliseconds since epoch
  # Formatting: look at
  # https://services.odata.org/V2/Northwind/Northwind.svc/Employees?$format=json
  # the json raw data is like this :   "HireDate": "\/Date(704678400000)\/"
  # --> \/\/
  strftime('/Date(%Q)/')
end