Class: Time
Class Method Summary collapse
- .human_readable_timestr(seconds, insertSpace = false) ⇒ Object
- .timestamp(options = {:short => false}) ⇒ Object
Instance Method Summary collapse
-
#micro_seconds ⇒ Object
Number of microseconds since Unix epoch.
-
#milli_seconds ⇒ Object
Number of milliseconds since Unix epoch.
-
#nano_seconds ⇒ Object
Number of nanoseconds since Unix epoch.
Class Method Details
.human_readable_timestr(seconds, insertSpace = false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/feldtruby/time.rb', line 28 def Time.human_readable_timestr(seconds, insertSpace = false) sp = insertSpace ? " " : "" if seconds < 1e-4 "%.2f#{sp}usec" % (seconds*1e6) elsif seconds < 1e-1 "%.2f#{sp}msec" % (seconds*1e3) elsif seconds > 60*60.0 "%.2f#{sp}hours" % (seconds/3600.0) elsif seconds > 60.0 "%.2f#{sp}mins" % (seconds/60.0) else "%.2f#{sp}sec" % seconds end end |
Instance Method Details
#micro_seconds ⇒ Object
Number of microseconds since Unix epoch.
9 10 11 |
# File 'lib/feldtruby/time.rb', line 9 def micro_seconds (to_i * 1_000_000) + (nsec / 1_000) end |
#milli_seconds ⇒ Object
Number of milliseconds since Unix epoch.
4 5 6 |
# File 'lib/feldtruby/time.rb', line 4 def milli_seconds (to_i * 1000) + (nsec / 1_000_000) end |
#nano_seconds ⇒ Object
Number of nanoseconds since Unix epoch.
14 15 16 |
# File 'lib/feldtruby/time.rb', line 14 def nano_seconds (to_i * 1_000_000_000) + nsec end |