couchrest_model/lib/couchrest.rb

29 lines
908 B
Ruby
Raw Normal View History

2008-08-03 12:51:17 -07:00
require "rubygems"
require 'json'
require 'rest_client'
require File.dirname(__FILE__) + '/couch_rest'
require File.dirname(__FILE__) + '/database'
require File.dirname(__FILE__) + '/pager'
require File.dirname(__FILE__) + '/file_manager'
2008-09-07 15:28:20 -07:00
require File.dirname(__FILE__) + '/streamer'
2008-03-18 11:37:10 -07:00
2008-09-10 14:37:30 -07:00
# this has to come after the JSON gem
2008-03-18 11:37:10 -07:00
2008-09-10 14:37:30 -07:00
# this date format sorts lexicographically
# and is compatible with Javascript's new Date(time_string) constructor
2008-09-10 16:19:28 -07:00
# note that sorting will break if you store times from multiple timezones
# I like to add a ENV['TZ'] = 'UTC' to my apps
2008-09-10 14:37:30 -07:00
class Time
def to_json(options = nil)
%("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
end
2008-09-10 16:19:28 -07:00
# this works to decode the outputted time format
# from ActiveSupport
# def self.parse string, fallback=nil
# d = DateTime.parse(string).new_offset
# self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec)
# rescue
# fallback
# end
2008-09-10 14:37:30 -07:00
end