Class: ActiveDirectory::FieldType::Timestamp

Inherits:
Object
  • Object
show all
Defined in:
lib/active_directory/field_type/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.



40
41
42
# File 'lib/active_directory/field_type/timestamp.rb', line 40

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)



32
33
34
# File 'lib/active_directory/field_type/timestamp.rb', line 32

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