Get unix time stamp from that given datetime. If datetime
    is not tzaware then it's assumed that it is UTC
483783
def unixtimestamp(datetime):
    
    epoch = UTC.localize(datetime.utcfromtimestamp(0))
    if not datetime.tzinfo:
        dt = UTC.localize(datetime)
    else:
        dt = UTC.normalize(datetime)
    delta = dt - epoch
    return total_seconds(delta)
1255577
def datetime2unix(T):
    
    T = atleast_1d(T)

    ut1_unix = empty(T.shape, dtype=float)
    for i, t in enumerate(T):
        if isinstance(t, (datetime, datetime64)):
            pass
        elif isinstance(t, str):
            try:
                ut1_unix[i] = float(t)  # it was ut1_unix in a string
                continue
            except ValueError:
                t = parse(t)  # datetime in a string
        elif isinstance(t, (float, int)):  # assuming ALL are ut1_unix already
            return T
        else:
            raise TypeError('I only accept datetime or parseable date string')

        # ut1 seconds since unix epoch, need [] for error case
        ut1_unix[i] = forceutc(t).timestamp()

    return ut1_unix
391401
def convert_iso_stamp(t, tz=None):
    """"""

    if t is None:
        return None

    dt = dateutil.parser.parse(t)
    if tz is not None:
        timezone = pytz.timezone(tz)
        if dt.tzinfo is None:
            dt = timezone.localize(dt)
    return dt
1245267
def to_unix(cls, timestamp):
        
        if not isinstance(timestamp, datetime.datetime):
            raise TypeError('Time.milliseconds expects a datetime object')
        base = time.mktime(timestamp.timetuple())
        return base
1221194
def load_unixtime(buf, pos):
    """"""
    secs, pos = load_le32(buf, pos)
    dt = datetime.fromtimestamp(secs, UTC)
    return dt, pos
647030
def current_timestamp(self) -> datetime:
        """"""
        timestamp = DB.get_hash_value(self._key, 'current_timestamp')
        return datetime_from_isoformat(timestamp)
315505
def _getFromDt(self):
        
        myNow = timezone.localtime(timezone=self.tz)
        return self.__after(myNow) or self.__before(myNow)
999572
def convertDatetime(t):
    
    epoch = datetime.datetime.utcfromtimestamp(0)
    delta = t - epoch
    millis = delta.total_seconds() * 1000
    return int(millis)
807697
def get_timestamp(dt=None):
    '''
    
    '''

    if dt is None: dt = datetime.datetime.utcnow()
    t = dt.utctimetuple()

    return calendar.timegm(t)
732481
def timestamp_from_datetime(date_time):
    """"""
    if date_time.tzinfo is None:
      return time.mktime((date_time.year, date_time.month, date_time.day, date_time.hour,
                          date_time.minute, date_time.second,
                          -1, -1, -1)) + date_time.microsecond / 1e6
    return (date_time - _EPOCH).total_seconds()
15766
def convert_tstamp(response):
	
	if response is None:
		# Allow passing None to convert_tstamp()
		return response

	# Overrides the set timezone to UTC - I think...
	tz = timezone.utc if settings.USE_TZ else None

	return datetime.datetime.fromtimestamp(response, tz)
362960
public static long unixTimestamp(String dateStr, String format, TimeZone tz) {
		long ts = parseToTimeMillis(dateStr, format, tz);
		if (ts == Long.MIN_VALUE) {
			return Long.MIN_VALUE;
		} else {
			// return the seconds
			return ts / 1000;
		}
	}
179591
def to_unix_ts(start_time):
    """"""
    if isinstance(start_time, datetime):
        if is_timezone_aware(start_time):
            start_time = start_time.astimezone(pytz.utc)
        else:
            log.warning(
                "Non timezone-aware datetime object passed to IncrementalEndpoint. "
                "The Zendesk API expects UTC time, if this is not the case results will be incorrect!"
            )
        unix_time = calendar.timegm(start_time.timetuple())
    else:
        unix_time = start_time

    return int(unix_time)
302982
def datetime_from_timestamp(timestamp, content):
    
    return set_date_tzinfo(
        datetime.fromtimestamp(timestamp),
        tz_name=content.settings.get('TIMEZONE', None))
644112
def timestamp_to_datetime(timestamp):
    """"""
    from datetime import datetime, timedelta
    obj = datetime.fromtimestamp(timestamp[0])
    return obj + timedelta(microseconds=int(timestamp[1]))
102178
def parse_datetime(dt):
    ''''''
    d = datetime.strptime(dt[:-1], ISOFORMAT)

    if dt[-1:] == 'Z':
        return timezone('utc').localize(d)
    else:
        return d
1123340
def timestamp_with_timezone(dt=None):
    
    dt = dt or datetime.now()
    if timezone is None:
        return dt.strftime('%Y-%m-%d %H:%M%z')
    if not dt.tzinfo:
        tz = timezone.get_current_timezone()
        if not tz:
            tz = timezone.utc
        dt = dt.replace(tzinfo=timezone.get_current_timezone())
    return dt.strftime("%Y-%m-%d %H:%M%z")