Certain fields in Active Directory are stored in “ticks” (1 tick == 100 nanoseconds).
To make using ticks easier in an app I wanted to add an additional time method to Numeric
(a lot like Active Support does… https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/numeric/time.rb)
It’s probably not the best way of doing it but in the end I added it using an initialiser:
# 'config/initializers/numeric.rb'
# Be sure to restart your server when you modify this file.
class Numeric
# Returns the number of ticks (100 nanoseconds) equivalent to the seconds provided.
# Used with the standard time durations.
#
# 2.in_ticks # => 20_000_000
# 1.hour.in_ticks # => 36_000_000_000
def in_ticks
self * 10_000_000
end
end