Sha256: 5586f304aba58d8563497cca222b61f409c1a490142bb705a800e4aaa331d7b1

Contents?: true

Size: 890 Bytes

Versions: 16

Compression:

Stored size: 890 Bytes

Contents

#include <internal/facts/windows/timezone_resolver.hpp>
#include <leatherman/logging/logging.hpp>
#include <boost/nowide/convert.hpp>
#include <ctime>

using namespace std;

namespace facter { namespace facts { namespace windows {

    string timezone_resolver::get_timezone()
    {
        time_t since_epoch = time(NULL);
        tm localtime;

        if (localtime_s(&localtime, &since_epoch)) {
            LOG_WARNING("localtime failed: timezone is unavailable: {1} ({2})", strerror(errno), errno);
            return {};
        }

        wchar_t buffer[256] = {};
        if (wcsftime(buffer, (sizeof(buffer) / sizeof(wchar_t)) - 1, L"%Z", &localtime) == 0) {
            LOG_WARNING("wcsftime failed: timezone is unavailable: {1} ({2})", strerror(errno), errno);
            return {};
        }
        return boost::nowide::narrow(buffer);
    }

}}}  // facter::facts::windows

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc