Class: ActiveDirectory::Timestamp

Inherits:
Object
  • Object
show all
Defined in:
lib/active_directory/timestamp.rb

Constant Summary collapse

AD_DIVISOR =

:nodoc:

10_000_000
AD_OFFSET =

:nodoc:

11_644_473_600

Class Method Summary collapse

Class Method Details

.decode(remote_time) ⇒ Object

Decodes an Active Directory timestamp (the number of 100 nanosecond time units since January 1, 1600) into a Ruby Time object.



42
43
44
# File 'lib/active_directory/timestamp.rb', line 42

def self.decode(remote_time)
	Time.at( (remote_time.to_i / AD_DIVISOR) - AD_OFFSET )
end

.encode(local_time) ⇒ Object

Encodes a local Time object (or the number of seconds since January 1, 1970) into a timestamp that the Active Directory server can understand (number of 100 nanosecond time units since January 1, 1600)



34
35
36
# File 'lib/active_directory/timestamp.rb', line 34

def self.encode(local_time)
	(local_time.to_i + AD_OFFSET) * AD_DIVISOR
end