Class: Time

Inherits:
Object
  • 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.)



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

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