Skip to content

Instantly share code, notes, and snippets.

@fragoulis
Created November 21, 2016 11:14
Show Gist options
  • Save fragoulis/3c78f50b7fc3181cd6241fb54dc13c64 to your computer and use it in GitHub Desktop.
Save fragoulis/3c78f50b7fc3181cd6241fb54dc13c64 to your computer and use it in GitHub Desktop.
Time extensions for
class Nanotime
def in_seconds(now = ::Time.current)
now.strftime("%s000000000")
end
def in_milliseconds(now = ::Time.current)
now.strftime("%s%3N000000")
end
def in_microseconds(now = ::Time.current)
now.strftime("%s%6N000")
end
def in_nanoseconds(now = ::Time.current)
now.strftime("%s%9N")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment