Class: Windows::File::Structs::SYSTEMTIME

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/win32/file/structs.rb

Instance Method Summary collapse

Constructor Details

#initialize(time = nil) ⇒ SYSTEMTIME

Allow a time object or raw numeric in constructor



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/win32/file/structs.rb', line 21

def initialize(time = nil)
  super()

  time = Time.at(time) if time.is_a?(Numeric)
  time = time.utc unless time.utc?

  self[:wYear] = time.year
  self[:wMonth] = time.month
  self[:wDayOfWeek] = time.wday
  self[:wDay] = time.day
  self[:wHour] = time.hour
  self[:wMinute] = time.min
  self[:wSecond] = time.sec
  self[:wMilliseconds] = time.nsec / 1000000
end