couchrest_model/lib/couchrest.rb

29 lines
908 B
Ruby
Raw Normal View History

2008-08-03 21:51:17 +02: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-08 00:28:20 +02:00
require File.dirname(__FILE__) + '/streamer'
2008-03-18 19:37:10 +01:00
2008-09-10 23:37:30 +02:00
# this has to come after the JSON gem
2008-03-18 19:37:10 +01:00
2008-09-10 23:37:30 +02:00
# this date format sorts lexicographically
# and is compatible with Javascript's new Date(time_string) constructor
2008-09-11 01:19:28 +02: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 23:37:30 +02:00
class Time
def to_json(options = nil)
%("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
end
2008-09-11 01:19:28 +02: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 23:37:30 +02:00
end