http://docs.python.org/library/datetime.html#datetime.tzinfo.utcoffset
336686
def utcoffset(self, dt):
        
        if self.__is_daylight_time(dt):
            return self.__dst_offset
        else:
            return self.__offset
567605
def utctimetuple(self):
        ""
        offset = self.utcoffset()
        if offset:
            self -= offset
        y, m, d = self.year, self.month, self.day
        hh, mm, ss = self.hour, self.minute, self.second
        return _build_struct_time(y, m, d, hh, mm, ss, 0)
866646
def _add_tzinfo(self, datetime_obj, tz_string):
        
        if datetime_obj is None:
            return None

        tzinfo_match = tz.gettz(tz_string)
        return datetime_obj.replace(tzinfo=tzinfo_match)
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
1132534
def _offset_to_min(utc_offset):
    '''
    
    '''
    match = re.match(r"^([+-])?(\d\d)(\d\d)$", utc_offset)
    if not match:
        raise SaltInvocationError("Invalid UTC offset")

    sign = -1 if match.group(1) == '-' else 1
    hours_offset = int(match.group(2))
    minutes_offset = int(match.group(3))
    total_offset = sign * (hours_offset * 60 + minutes_offset)
    return total_offset
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
250428
def to_naive_utc(dtime):
    
    if not hasattr(dtime, 'tzinfo') or dtime.tzinfo is None:
        return dtime

    dtime_utc = dtime.astimezone(pytz.UTC)
    dtime_naive = dtime_utc.replace(tzinfo=None)
    return dtime_naive
1007761
def format_as_utc(self, value):
        """"""
        if isinstance(value, datetime.datetime):
            if value.tzinfo is not None:
                value = value.astimezone(pytz.UTC)
            value = value.replace(microsecond=0)
        return value.isoformat().replace('+00:00', 'Z')
800749
def localize(dt):
    """"""
    if dt.tzinfo is UTC:
        return (dt + LOCAL_UTC_OFFSET).replace(tzinfo=None)
    # No TZ info so not going to assume anything, return as-is.
    return dt
1182966
def utc_offset_by_timezone(timezone_name):
    
    return int(pytz.timezone(timezone_name).utcoffset(
        utc_time()).total_seconds()/SECONDS_IN_HOUR)
139599
def _to_utc(self, dt):
        """"""
        tz = self._get_tz()
        loc_dt = tz.localize(dt)
        return loc_dt.astimezone(pytz.utc)
757933
def from_timestamp(timestamp, tz_offset):
    """"""
    utc_dt = datetime.fromtimestamp(timestamp, utc)
    try:
        local_dt = utc_dt.astimezone(tzoffset(tz_offset))
        return local_dt
    except ValueError:
        return utc_dt
1275224
def today_as_utc_datetime():
    """"""
    now = today()
    if not isinstance(now, datetime) and isinstance(now, date):
        now = datetime.combine(now, datetime.min.time())
        now = now.replace(tzinfo=tz.gettz('UTC'))
    return now
208973
private static DateTime readOffset(boolean isPlus, TimeZone timeZone, DateTime dt, int years, int months, int days, int hours, int minutes, int seconds, int milliSeconds,
	    DateString ds, boolean checkAfterLast, DateTime defaultValue) {
	// timeZone=ThreadLocalPageContext.getTimeZone(timeZone);
	if (timeZone == null) return defaultValue;
	// HOUR
	int hourLength = ds.getPos();
	int hour = ds.readDigits();
	hourLength = ds.getPos() - hourLength;
	if (hour == -1) return defaultValue;

	// MINUTE
	int minute = 0;
	if (!ds.isAfterLast()) {
	    if (!(ds.fwIfCurrent(':') || ds.fwIfCurrent('.'))) return defaultValue;
	    minute = ds.readDigits();
	    if (minute == -1) return defaultValue;

	}
	else if (hourLength > 2) {
	    int h = hour / 100;
	    minute = hour - (h * 100);
	    hour = h;
	}

	if (minute > 59) return defaultValue;
	if (hour > 14 || (hour == 14 && minute > 0)) return defaultValue;

	long offset = hour * 60L * 60L * 1000L;
	offset += minute * 60 * 1000;

	if (!checkAfterLast || ds.isAfterLast()) {
	    long time = util.toTime(TimeZoneConstants.UTC, years, months, days, hours, minutes, seconds, milliSeconds, 0);

	    if (isPlus) time -= offset;
	    else time += offset;
	    return new DateTimeImpl(time, false);
	}
	return defaultValue;
    }
456704
def __consistent_isoformat_utc(datetime_val):
        
        isotime = datetime_val.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S%z")
        if isotime[-2] != ":":
            isotime = isotime[:-2] + ":" + isotime[-2:]
        return isotime
331864
function getStandardTimeOffset(date) {
  var jan = new Date(date.getFullYear(), 0, 1);
  var jul = new Date(date.getFullYear(), 6, 1);
  return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}
412377
def datetime_to_timestamp(dt):
    

    epoch = datetime.utcfromtimestamp(0).replace(tzinfo=UTC)
    return (dt - epoch).total_seconds()