Class: Time

Inherits:
Object show all
Defined in:
lib/couchrest/monkeypatches.rb

Overview

This file must be loaded after the JSON gem and any other library that beats up the Time class.

Instance Method Summary collapse

Instance Method Details

#to_json(options = nil) ⇒ Object

This date format sorts lexicographically and is compatible with Javascript’s new Date(time_string) constructor. Note this this format stores all dates in UTC so that collation order is preserved. (There’s no longer a need to set ENV['TZ'] = 'UTC' in your application.)



12
13
14
15
# File 'lib/couchrest/monkeypatches.rb', line 12

def to_json(options = nil)
  u = self.utc
  %("#{u.strftime("%Y/%m/%d %H:%M:%S +0000")}")
end