Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created Feb 21, 2021
Embed
What would you like to do?
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