Sha256: 35f85eeacbb8665824ae228d014db5423803345a18ebc281ca9ed282aa4f9374
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Facter module Resolvers module Windows class Timezone < BaseResolver init_resolver class << self private def post_resolve(fact_name, _options) @fact_list.fetch(fact_name) { determine_timezone } end 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 def codepage result = codepage_from_api result&.empty? ? codepage_from_registry : result end def codepage_from_registry require 'win32/registry' ::Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\CurrentControlSet\Control\Nls\CodePage')['ACP'] end def codepage_from_api require_relative '../../../facter/resolvers/windows/ffi/winnls_ffi' WinnlsFFI.GetACP.to_s end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
facter-4.4.3 | lib/facter/resolvers/windows/timezone.rb |
facter-4.4.2 | lib/facter/resolvers/windows/timezone.rb |