Skip to content

Instantly share code, notes, and snippets.

@suginoy
Created December 2, 2017 15:27
Show Gist options
  • Save suginoy/c4bc004f6b3deac2186bfb73d94e30df to your computer and use it in GitHub Desktop.
Save suginoy/c4bc004f6b3deac2186bfb73d94e30df to your computer and use it in GitHub Desktop.
Implement Javascript's Date#getTime() in Ruby
# JavaScript の Date#getTime は Ruby の Time#to_i と違い、 UNIX 時刻のミリ秒まで入る
class Time
def javascript_date_get_time
("#{to_i * 1000}#{('%03d' % (usec / 1000))}").to_i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment