Skip to content

Instantly share code, notes, and snippets.

@ngty
Created August 2, 2010 07:08
Show Gist options
  • Save ngty/504251 to your computer and use it in GitHub Desktop.
Save ngty/504251 to your computer and use it in GitHub Desktop.
# instead of Time.now (or watever class methods of Time), we use:
LocalTime.now
When %r{I press "([^"]*)" at "([^"]*)"$} do |button, timing|
LocalTime.xstub(:now => LocalTime.parse(timing))
When %|I press "#{button}"|
end
class LocalTime
@@zone = Time.zone
class << self
def method_missing(method, *args)
args.empty? ? @@zone.send(method) : @@zone.send(method, *args)
end
end
end
Rails::Initializer.run do |config|
# lots of other stuff
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'Singapore'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment