Get current numeric timezone offset from UTC (i.e. -0700)

    Returns:
        str: Offset from UTC

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_offset
188076
def get_offset():
    '''
    
    '''
    # http://craigglennie.com/programming/python/2013/07/21/working-with-timezones-using-Python-and-pytz-localize-vs-normalize/
    tz_object = pytz.timezone(get_zone())
    utc_time = pytz.utc.localize(datetime.utcnow())
    loc_time = utc_time.astimezone(tz_object)
    norm_time = tz_object.normalize(loc_time)
    return norm_time.strftime('%z')
282389
def fixed_timezone(offset):  # type: (int) -> _FixedTimezone
    
    if offset in _tz_cache:
        return _tz_cache[offset]

    tz = _FixedTimezone(offset)
    _tz_cache[offset] = tz

    return tz
744955
def dst(self, dt):
        
        if self.__is_daylight_time(dt):
            return self.__dst_offset - self.__offset
        else:
            return datetime.timedelta(0)
99524
def getUTC(self):
        
        timeUTC = self.time.getUTC(self.utcoffset)
        dateUTC = Date(round(self.jd))
        return Datetime(dateUTC, timeUTC)
1219576
def to_utc(value, defaulttz=None):
    
    if defaulttz is None:
        defaulttz = tzlocal()
    return _convert(value, tzutc(), defaulttz)
844134
def milliseconds_offset(cls, timestamp, now=None):
        
        if isinstance(timestamp, (int, float)):
            base = timestamp
        else:
            base = cls.to_unix(timestamp)
            base += (timestamp.microsecond / 1000000)
        if now is None:
            now = time.time()
        return (now - base) * 1000
1071298
def _get_timezone(self, tz):
        
        # special Local timezone
        if tz == "Local":
            try:
                return tzlocal.get_localzone()
            except pytz.UnknownTimeZoneError:
                return "?"

        # we can use a country code to get tz
        # FIXME this is broken for multi-timezone countries eg US
        # for now we just grab the first one
        if len(tz) == 2:
            try:
                zones = pytz.country_timezones(tz)
            except KeyError:
                return "?"
            tz = zones[0]

        # get the timezone
        try:
            zone = pytz.timezone(tz)
        except pytz.UnknownTimeZoneError:
            return "?"
        return zone
529564
function offset(date) {
        // Difference to Greenwich time (GMT) in hours
        var os = Math.abs(date.getTimezoneOffset());
        var h = String(Math.floor(os/60));
        var m = String(os%60);
        h.length === 1? h = '0'+h:1;
        m.length === 1? m = '0'+m:1;
        return date.getTimezoneOffset() < 0 ? '+'+h+m : '-'+h+m;
    }
286037
def altz_to_utctz_str(altz):
    """"""
    utci = -1 * int((float(altz) / 3600) * 100)
    utcs = str(abs(utci))
    utcs = "0" * (4 - len(utcs)) + utcs
    prefix = (utci < 0 and '-') or '+'
    return prefix + utcs
387870
def today(date_time=None):
    
    ret = date_time or cst_now()
    try:
        ret = datetime(year=ret.year, month=ret.month, day=ret.day)
        if DEFAULT_TIMEZONE_AWARE:
            ret = ret.replace(
                tzinfo=psycopg2.tz.FixedOffsetTimezone(
                    name=None, offset=DEFAULT_TIMEZONE * 60))
    except Exception as ex:
        pass
    return ret
685867
protected int getOffset(long dt)
    {
        int ret = 0;
        TimeZone tz = DateUtilities.getCurrentTimeZone();
        if(tz != null)
            ret = tz.getOffset(dt);
        return ret;
    }
1134372
def Z(self):
    
    if not self.timezone:
      return 0
    offset = self.timezone.utcoffset(self.data)
    # Only days can be negative, so negative offsets have days=-1 and
    # seconds positive. Positive offsets have days=0
    return offset.days * 86400 + offset.seconds
582507
def get_zone():
    '''
    
    '''
    cmd = ['tzutil', '/g']
    res = __salt__['cmd.run_all'](cmd, python_shell=False)
    if res['retcode'] or not res['stdout']:
        raise CommandExecutionError('tzutil encountered an error getting '
                                    'timezone',
                                    info=res)
    return mapper.get_unix(res['stdout'].lower(), 'Unknown')
545676
def date_utc(self) -> datetime:
        """"""
        return datetime.utcfromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"])
382760
def get_utc_timestamp(self, handle):
        """"""
        fpath = self._fpath_from_handle(handle)
        datetime_obj = datetime.datetime.utcfromtimestamp(
            os.stat(fpath).st_mtime
        )
        return timestamp(datetime_obj)
612386
def dst(self, dt):
        
        if not self._is_dst(dt):
            return datetime.timedelta(0)

        offset = time.timezone - time.altzone
        return datetime.timedelta(seconds=-offset)
801943
def get_now_utc_notz_datetime() -> datetime.datetime:
    
    now = datetime.datetime.utcnow()
    return now.replace(tzinfo=None)