Given a timezone offset in minutes, and  a JS Date object,
returns the delta in milliseconds, of the two timezones.
Note that this will include the offset contributions from DST for both.
515379
function(serverOffsetThen, d) {
            if (!Splunk.util.isInt(serverOffsetThen)) {
                return 0;
            }
            // what JS thinks the timezone offset is at the time given by d. This WILL INCLUDE DST
            var clientOffsetThen = d.getTimezoneOffset() * 60;
            // what splunkd told is the actual timezone offset.
            serverOffsetThen     = serverOffsetThen * -60;

            return 1000 * (serverOffsetThen - clientOffsetThen);
        }
210794
function parseTimezoneOffset (offset) {
  let [, sign, hours, minutes] = offset.match(/(\+|-)(\d\d)(\d\d)/)
  minutes = (sign === '+' ? 1 : -1) * (Number(hours) * 60 + Number(minutes))
  return negateExceptForZero(minutes)
}
428653
def get_expire_delta(self, reference=None):
        
        if reference is None:
            reference = now()
        expiration = self.expires

        if timezone:
            if timezone.is_aware(reference) and timezone.is_naive(expiration):
                # MySQL doesn't support timezone for datetime fields
                # so we assume that the date was stored in the UTC timezone
                expiration = timezone.make_aware(expiration, timezone.utc)
            elif timezone.is_naive(reference) and timezone.is_aware(expiration):
                reference = timezone.make_aware(reference, timezone.utc)

        timedelta = expiration - reference
        return timedelta.days*86400 + timedelta.seconds
1338654
def dst(self, dt):
        """"""
        tt = _localtime(_mktime((dt.year, dt.month, dt.day,
                 dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
        if tt.tm_isdst > 0: return _dstdiff
        return _zero
578449
public byte[] getData(byte[] dst, int offset)
	{
		final int end = Math.min(data.length, dst.length - offset) & ~0x01;
		for (int i = 0; i < end; ++i)
			dst[offset + i] = (byte) data[i];
		return dst;
	}

	/**
	 * Sets the first translation item value from input of unit millisecond.
	 * <p>
	 * The method is for DPTs dealing with periods of time, in particular
	 * {@link #DPT_TIMEPERIOD}, {@link #DPT_TIMEPERIOD_10}, {@link #DPT_TIMEPERIOD_100}
	 * {@link #DPT_TIMEPERIOD_SEC}, {@link #DPT_TIMEPERIOD_MIN} and
	 * {@link #DPT_TIMEPERIOD_HOURS}. The milliseconds are converted to the unit of the
	 * set DPT, with the result rounded to the nearest representable value (with 0.5
	 * rounded up).<br>
	 * On any other DPT, the input is treated equal to {@link #setValue(int)}.
	 * 
	 * @param milliseconds the value in milliseconds, 0 &lt;= <code>milliseconds</code>
	 * @throws KNXFormatException on milliseconds out of range for DPT
	 */
	public final void setTimePeriod(long milliseconds) throws KNXFormatException
	{
		data = toDPT(milliseconds);
	}

	/* (non-Javadoc)
	 * @see tuwien.auto.calimero.dptxlator.DPTXlator#getSubTypes()
	 */
	public final Map getSubTypes()
	{
		return types;
	}

	/**
	 * @return the subtypes of the 2-byte unsigned translator type
	 * @see DPTXlator#getSubTypesStatic()
	 */
	protected static Map getSubTypesStatic()
	{
		return types;
	}

	private int fromDPT(int index)
	{
		final int v = (data[2 * index] << 8) | data[2 * index + 1];
		if (dpt.equals(DPT_TIMEPERIOD_10))
			return v * 10;
		else if (dpt.equals(DPT_TIMEPERIOD_100))
			return v * 100;
		return v;
	}

	private String makeString(int index)
	{
		return appendUnit(String.valueOf(fromDPT(index)));
	}

	protected void toDPT(String value, short[] dst, int index) throws KNXFormatException
	{
		try {
			toDPT(Integer.decode(removeUnit(value)).intValue(), dst, index);
		}
		catch (final NumberFormatException e) {
			throw logThrow(LogLevel.WARN, "wrong value format " + value, null, value);
		}
	}

	private short[] toDPT(long ms) throws KNXFormatException
	{
		// prevent round up to 0 from negative milliseconds
		if (ms < 0)
			throw logThrow(LogLevel.WARN, "negative input value " + Long.toString(ms),
				null, Long.toString(ms));
		long v = ms;
		if (dpt.equals(DPT_TIMEPERIOD_SEC))
			v = Math.round(ms / 1000.0);
		else if (dpt.equals(DPT_TIMEPERIOD_MIN))
			v = Math.round(ms / 1000.0 / 60.0);
		else if (dpt.equals(DPT_TIMEPERIOD_HOURS))
			v = Math.round(ms / 1000.0 / 60.0 / 60.0);
		final short[] buf = new short[2];
		toDPT((int) v, buf, 0);
		return buf;
	}
318920
def _timestamps_eq(a, b):
    """"""
    assert isinstance(a, datetime)
    if not isinstance(b, datetime):
        return False
    # Local offsets must be equivalent.
    if (a.tzinfo is None) ^ (b.tzinfo is None):
        return False
    if a.utcoffset() != b.utcoffset():
        return False
    for a, b in ((a, b), (b, a)):
        if isinstance(a, Timestamp):
            if isinstance(b, Timestamp):
                # Both operands declare their precisions. They are only equivalent if their precisions are the same.
                if a.precision is b.precision and a.fractional_precision is b.fractional_precision:
                    break
                return False
            elif a.precision is not TimestampPrecision.SECOND or a.fractional_precision != MICROSECOND_PRECISION:
                # Only one of the operands declares its precision. It is only equivalent to the other (a naive datetime)
                # if it has full microseconds precision.
                return False
    return a == b
460188
def _subtract_timedelta(self, delta):
        
        if isinstance(delta, pendulum.Duration):
            return self.subtract(
                years=delta.years,
                months=delta.months,
                weeks=delta.weeks,
                days=delta.remaining_days,
                hours=delta.hours,
                minutes=delta.minutes,
                seconds=delta.remaining_seconds,
                microseconds=delta.microseconds,
            )

        return self.subtract(
            days=delta.days, seconds=delta.seconds, microseconds=delta.microseconds
        )
171645
function time(start) {
  let delta = new Date() - start;
  delta = delta < 10000 ? `${delta}ms` : `${Math.round(delta / 1000)}s`;
  return humanize(delta);
}
1366654
def dt_delta(dt, delta):
    
    delta_time = datetime.timedelta(days=delta)
    target_date = dt + delta_time
    return target_date
883766
def delta(self):
        """"""
        end_time = self.end_time if self.end_time else dt.datetime.now()
        return end_time - self.start_time
287245
def get_dst(date_obj):
    """"""
    dst = 0
    if date_obj.year >= 1900:
        tmp_date = time.mktime(date_obj.timetuple())
        # DST is 1 so reduce time with 1 hour.
        dst = time.localtime(tmp_date)[-1]
    return dst
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;
    }
856124
def delta(d1, d2, opt='d'):
    
    delta = 0

    if opt == 'm':
        while True:
            mdays = monthrange(d1.year, d1.month)[1]
            d1 += timedelta(days=mdays)
            if d1 <= d2:
                delta += 1
            else:
                break
    else:
        delta = (d2 - d1).days

    return delta
1130664
def timezone(utcoffset):
    '''
    

    '''

    hours, seconds = divmod(abs(utcoffset), 3600)
    minutes = round(float(seconds) / 60)

    if utcoffset >= 0:
        sign = '+'
    else:
        sign = '-'
    return '{0}{1:02d}:{2:02d}'.format(sign, int(hours), int(minutes))
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());
}
1023810
function getFuzzyLocalTimeFromPoint(timestamp, point) {
  var tile = tilebelt.pointToTile(point[0], point[1], z).join('/');
  var locale = tiles[tile];

  if (locale) return moment.tz(new Date(timestamp), locale);
  else return undefined;
}
41926
def date2timestamp(dte):
    ''''''
    seconds = mktime(dte.timetuple())
    if isinstance(dte, datetime):
        return seconds + dte.microsecond / 1000000.0
    else:
        return int(seconds)