class Facter::Resolvers::Windows::Timezone
Private Class Methods
codepage()
click to toggle source
# File lib/facter/resolvers/windows/timezone.rb, line 23 def codepage result = codepage_from_api result&.empty? ? codepage_from_registry : result end
codepage_from_api()
click to toggle source
# File lib/facter/resolvers/windows/timezone.rb, line 33 def codepage_from_api require_relative '../../../facter/resolvers/windows/ffi/winnls_ffi' WinnlsFFI.GetACP.to_s rescue LoadError => e log.debug("Could not retrieve codepage: #{e}") end
codepage_from_registry()
click to toggle source
# File lib/facter/resolvers/windows/timezone.rb, line 28 def codepage_from_registry require 'win32/registry' ::Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\CurrentControlSet\Control\Nls\CodePage')['ACP'] end
determine_timezone()
click to toggle source
# File lib/facter/resolvers/windows/timezone.rb, line 16 def determine_timezone timezone = Time.now.zone @fact_list[:timezone] = timezone.force_encoding("CP#{codepage}").encode('UTF-8', invalid: :replace) rescue ArgumentError @fact_list[:timezone] = timezone end
post_resolve(fact_name, _options)
click to toggle source
# File lib/facter/resolvers/windows/timezone.rb, line 12 def post_resolve(fact_name, _options) @fact_list.fetch(fact_name) { determine_timezone } end