Get current hardware clock setting (UTC or localtime)

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_hwclock
343997
def get_hwclock():
    '''
    
    '''
    if salt.utils.path.which('timedatectl'):
        ret = _timedatectl()
        for line in (x.strip() for x in ret['stdout'].splitlines()):
            if 'rtc in local tz' in line.lower():
                try:
                    if line.split(':')[-1].strip().lower() == 'yes':
                        return 'localtime'
                    else:
                        return 'UTC'
                except IndexError:
                    pass

        msg = ('Failed to parse timedatectl output: {0}\n'
               'Please file an issue with SaltStack').format(ret['stdout'])
        raise CommandExecutionError(msg)

    else:
        os_family = __grains__['os_family']
        for family in ('RedHat', 'Suse', 'NILinuxRT'):
            if family in os_family:
                return _get_adjtime_timezone()

        if 'Debian' in __grains__['os_family']:
            # Original way to look up hwclock on Debian-based systems
            try:
                with salt.utils.files.fopen('/etc/default/rcS', 'r') as fp_:
                    for line in fp_:
                        line = salt.utils.stringutils.to_unicode(line)
                        if re.match(r'^\s*#', line):
                            continue
                        if 'UTC=' in line:
                            is_utc = line.rstrip('\n').split('=')[-1].lower()
                            if is_utc == 'yes':
                                return 'UTC'
                            else:
                                return 'localtime'
            except IOError as exc:
                pass
            # Since Wheezy
            return _get_adjtime_timezone()

        if 'Gentoo' in __grains__['os_family']:
            if not os.path.exists('/etc/adjtime'):
                offset_file = '/etc/conf.d/hwclock'
                try:
                    with salt.utils.files.fopen(offset_file, 'r') as fp_:
                        for line in fp_:
                            line = salt.utils.stringutils.to_unicode(line)
                            if line.startswith('clock='):
                                line = line.rstrip('\n')
                                line = line.split('=')[-1].strip('\'"')
                                if line == 'UTC':
                                    return line
                                if line == 'local':
                                    return 'LOCAL'
                        raise CommandExecutionError(
                            'Correct offset value not found in {0}'
                            .format(offset_file)
                        )
                except IOError as exc:
                    raise CommandExecutionError(
                        'Problem reading offset file {0}: {1}'
                        .format(offset_file, exc.strerror)
                    )
            return _get_adjtime_timezone()

        if 'Solaris' in __grains__['os_family']:
            offset_file = '/etc/rtc_config'
            try:
                with salt.utils.files.fopen(offset_file, 'r') as fp_:
                    for line in fp_:
                        line = salt.utils.stringutils.to_unicode(line)
                        if line.startswith('zone_info=GMT'):
                            return 'UTC'
                    return 'localtime'
            except IOError as exc:
                if exc.errno == errno.ENOENT:
                    # offset file does not exist
                    return 'UTC'
                raise CommandExecutionError(
                    'Problem reading offset file {0}: {1}'
                    .format(offset_file, exc.strerror)
                )

        if 'AIX' in __grains__['os_family']:
            offset_file = '/etc/environment'
            try:
                with salt.utils.files.fopen(offset_file, 'r') as fp_:
                    for line in fp_:
                        line = salt.utils.stringutils.to_unicode(line)
                        if line.startswith('TZ=UTC'):
                            return 'UTC'
                    return 'localtime'
            except IOError as exc:
                if exc.errno == errno.ENOENT:
                    # offset file does not exist
                    return 'UTC'
                raise CommandExecutionError(
                    'Problem reading offset file {0}: {1}'
                    .format(offset_file, exc.strerror)
                )
333590
def GetCpuReservationMHz(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetCpuReservationMHz(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value
466242
def get_time():
    '''
    
    '''
    ret = salt.utils.mac_utils.execute_return_result('systemsetup -gettime')
    return salt.utils.mac_utils.parse_return(ret)
684544
private static Calendar _getThreadCalendar(Locale l, TimeZone tz) {
	Calendar c = _localeCalendar.get(tz, l);
	if (tz == null) tz = ThreadLocalPageContext.getTimeZone();
	c.setTimeZone(tz);
	return c;
    }
1117510
def _get_cached_time(self):
        
        if not self._cached_time:
            self._cached_time = self._meta.datetime.utcnow()

        return self._cached_time
1103210
synchronized TimeData getCurrentTime(boolean withZone) {

        resetCurrentTimestamp();

        if (withZone) {
            if (currentTime == null) {
                int seconds =
                    (int) (HsqlDateTime.getNormalisedTime(currentMillis))
                    / 1000;
                int nanos = (int) (currentMillis % 1000) * 1000000;

                currentTime = new TimeData(seconds, nanos, timeZoneSeconds);
            }

            return currentTime;
        } else {
            if (localTime == null) {
                int seconds =
                    (int) (HsqlDateTime.getNormalisedTime(
                        currentMillis + +timeZoneSeconds * 1000)) / 1000;
                int nanos = (int) (currentMillis % 1000) * 1000000;

                localTime = new TimeData(seconds, nanos, 0);
            }

            return localTime;
        }
    }
332500
def get_zone():
    '''
    
    '''
    ret = salt.utils.mac_utils.execute_return_result('systemsetup -gettimezone')
    return salt.utils.mac_utils.parse_return(ret)
273602
def local_timezone
      tzname = Time.new.zone
      q, r = Time.new.utc_offset.divmod(3600)
      sign = (q < 0) ? '-' : '+'
      tzoffset = sign + "%02d" % q.abs.to_s + ':' + r.to_f.div(60).to_s
      "#{tzname} (UTC#{tzoffset})"
    end
184653
def cst_now():
    
    try:
        ret = datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
        if DEFAULT_TIMEZONE_AWARE:
            ret = ret.replace(
                tzinfo=psycopg2.tz.FixedOffsetTimezone(
                    name=None, offset=DEFAULT_TIMEZONE * 60))
        return ret
    except Exception as ex:
        return datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
646821
def get_current_time(self):
        
        hms = [int(self.get_current_controller_value(i)) for i in range(406, 409)]
        return datetime.time(*hms)
739037
def reload_localzone():
    """"""
    global _cache_tz
    _cache_tz = pytz.timezone(get_localzone_name())
    utils.assert_tz_offset(_cache_tz)
    return _cache_tz
328379
def get_start_time(self):
        
        if win32.PROCESS_ALL_ACCESS == win32.PROCESS_ALL_ACCESS_VISTA:
            dwAccess = win32.PROCESS_QUERY_LIMITED_INFORMATION
        else:
            dwAccess = win32.PROCESS_QUERY_INFORMATION
        hProcess = self.get_handle(dwAccess)
        CreationTime = win32.GetProcessTimes(hProcess)[0]
        return win32.FileTimeToSystemTime(CreationTime)
976982
def get_using_network_time():
    '''
    
    '''
    ret = salt.utils.mac_utils.execute_return_result(
        'systemsetup -getusingnetworktime')

    return salt.utils.mac_utils.validate_enabled(
        salt.utils.mac_utils.parse_return(ret)) == 'on'
149741
def getLocalDatetime(date, time, tz=None, timeDefault=dt.time.max):
    
    localTZ = timezone.get_current_timezone()
    if tz is None or tz == localTZ:
        localDt = getAwareDatetime(date, time, tz, timeDefault)
    else:
        # create in event's time zone
        eventDt = getAwareDatetime(date, time, tz, timeDefault)
        # convert to local time zone
        localDt = eventDt.astimezone(localTZ)
        if time is None:
            localDt = getAwareDatetime(localDt.date(), None, localTZ, timeDefault)
    return localDt
1261453
def get_system_time():
    '''
    
    '''
    now = win32api.GetLocalTime()
    meridian = 'AM'
    hours = int(now[4])
    if hours == 12:
        meridian = 'PM'
    elif hours == 0:
        hours = 12
    elif hours > 12:
        hours = hours - 12
        meridian = 'PM'
    return '{0:02d}:{1:02d}:{2:02d} {3}'.format(hours, now[5], now[6], meridian)
765970
def timers_get
      hash = {}
      hash[:hello] = default_timers_hello
      hash[:mshello] = default_timers_hello_msec
      hash[:hold] = default_timers_hold
      hash[:mshold] = default_timers_hold_msec
      str = config_get('interface_hsrp_group', 'timers', @get_args)
      return hash if str.nil?
      regexp = Regexp.new('(?<msec1>msec)?'\
               ' *(?<he>\d+) *(?<msec2>msec)? *(?<ho>\d+)')
      params = regexp.match(str)
      hash[:mshello] = true if params[:msec1]
      hash[:mshold] = true if params[:msec2]
      hash[:hello] = params[:he].to_i
      hash[:hold] = params[:ho].to_i
      hash
    end
759890
def get_zonecode():
    '''
    
    '''
    tz_object = pytz.timezone(get_zone())
    loc_time = tz_object.localize(datetime.utcnow())
    return loc_time.tzname()