Skip to content

Instantly share code, notes, and snippets.

@johnnaegle
Created April 8, 2014 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnaegle/10086659 to your computer and use it in GitHub Desktop.
Save johnnaegle/10086659 to your computer and use it in GitHub Desktop.
Demonstrates that ActiveSupport::TimeWithZone has milliseconds in Rails 4.0
gem 'activesupport', '4.0.4'
require 'active_support/time'
require 'active_support/time_with_zone'
require 'active_support/core_ext/date_time/zones.rb'
require 'minitest/autorun'
class UserTest < MiniTest::Unit::TestCase
def test_no_milliseconds
time = ActiveSupport::TimeWithZone.new(Time.now, Time.find_zone!('UTC'))
assert_equal 1, time.as_json.split('.').length
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment