Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created February 21, 2021 06: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 hyuki/9d2eeca2e29cd19327fda774fe4ba530 to your computer and use it in GitHub Desktop.
Save hyuki/9d2eeca2e29cd19327fda774fe4ba530 to your computer and use it in GitHub Desktop.
Time compare
system("echo Hello > a")
system("echo Hello > b")
system("touch -r a b")
a = File.mtime("a")
b = File.mtime("b")
puts "File.mtime('a') => #{a}"
puts "File.mtime('b') => #{b}"
puts "File.mtime('a').to_i => #{a.to_i}"
puts "File.mtime('b').to_i => #{b.to_i}"
puts "File.mtime('a').usec => #{a.usec}"
puts "File.mtime('b').usec => #{b.usec}"
puts "File.mtime('a').nsec => #{a.nsec}"
puts "File.mtime('b').nsec => #{b.nsec}"
puts "(File.mtime('a') == File.mtime('b')) => #{a == b}"
@hyuki
Copy link
Author

hyuki commented Feb 21, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment