Skip to content

Instantly share code, notes, and snippets.

@flyinprogrammer
Created June 11, 2013 18:12
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 flyinprogrammer/5759301 to your computer and use it in GitHub Desktop.
Save flyinprogrammer/5759301 to your computer and use it in GitHub Desktop.
inverted timezone in jruby?
class Time

  # Convert a time that is 'milliseconds since epoch' to a Time object
  #
  # @return [Time] A time object created from a 'milliseconds since epoch' timestamp
  def self.from_millisecond_epoch time
    Time.at(time / 1000)
  end

end

in ruby 1.9.3-p429 this passes:

Time.from_millisecond_epoch(1366658285432).should eql Time.new(2013,4,22,14,18,05,'-05:00')

in jruby 1.7.4 it doesn't, I get:

expected: 2013-04-22 14:18:05 +0500
     got: 2013-04-22 14:18:05 -0500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment