Class Ole::Types::FileTime
In: lib/ole/types/base.rb
Parent: DateTime
String Data Lpstr Clsid Lpwstr Section Enumerable DateTime FileTime Constants Variant::Constants Storage\n[lib/ole/storage/base.rb\nlib/ole/storage/file_system.rb\nlib/ole/storage/meta_data.rb] PropertySet lib/ole/storage/file_system.rb lib/ole/types/property_set.rb lib/ole/types/base.rb Constants Constants Variant Types Ole dot/m_9_0.png

for VT_FILETIME

Methods

dump   inspect   load  

Constants

SIZE = 8
EPOCH = new 1601, 1, 1

Public Class methods

time should be able to be either a Time, Date, or DateTime.

[Source]

    # File lib/ole/types/base.rb, line 84
84:                         def self.dump time
85:                                 # i think i'll convert whatever i get to be a datetime, because of
86:                                 # the covered range.
87:                                 return 0.chr * SIZE unless time
88:                                 time = time.send(:to_datetime) if Time === time
89:                                 # don't bother to use const_get here
90:                                 bignum = (time - EPOCH) * 86400 * 1e7.to_i
91:                                 high, low = bignum.divmod 1 << 32
92:                                 [low, high].pack 'V2'
93:                         end

Create a DateTime object from a struct FILETIME (msdn2.microsoft.com/en-us/library/ms724284.aspx).

Converts str to two 32 bit time values, comprising the high and low 32 bits of the 100‘s of nanoseconds since 1st january 1601 (Epoch).

[Source]

    # File lib/ole/types/base.rb, line 67
67:                         def self.load str
68:                                 low, high = str.to_s.unpack 'V2'
69:                                 # we ignore these, without even warning about it
70:                                 return nil if low == 0 and high == 0
71:                                 # switched to rational, and fixed the off by 1 second error i sometimes got.
72:                                 # time = EPOCH + (high * (1 << 32) + low) / 1e7 / 86400 rescue return
73:                                 # use const_get to ensure we can return anything which subclasses this (VT_DATE?)
74:                                 const_get('EPOCH') + Rational(high * (1 << 32) + low, 1e7.to_i * 86400) rescue return
75:                                 # extra sanity check...
76:                                 #unless (1800...2100) === time.year
77:                                 #   Log.warn "ignoring unlikely time value #{time.to_s}"
78:                                 #   return nil
79:                                 #end
80:                                 #time
81:                         end

Public Instance methods

[Source]

    # File lib/ole/types/base.rb, line 95
95:                         def inspect
96:                                 "#<#{self.class} #{to_s}>"
97:                         end

[Validate]