Return date/time for start of last session data.
166502
def last_session_date(self):
        """"""
        try:
            date = self.intervals[1]['ts']
        except KeyError:
            return None
        date_f = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ')
        now = time.time()
        offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)
        return date_f + offset
275635
def _get_date(data, position, dummy0, opts, dummy1):
    """"""
    end = position + 8
    millis = _UNPACK_LONG(data[position:end])[0]
    return _millis_to_datetime(millis, opts), end
485855
def run_etime(self):
        """"""
        if self.start_datetime is None or self.end_datetime is None:
            return None

        return self.end_datetime - self.start_datetime
739594
def request_time(self) -> float:
        """"""
        if self._finish_time is None:
            return time.time() - self._start_time
        else:
            return self._finish_time - self._start_time
141392
def get_last_status_in_session(self, session):
        
        try:
            return self._last_status_in_session[session]
        except KeyError:
            raise errors.Error('The session %r does not seem to be valid as it does not have any last status' % session)
913749
def datetime(self):
        """"""
        return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc)
966818
def get_time():
    """"""

    time_request = '\x1b' + 47 * '\0'
    now = struct.unpack("!12I", ntp_service.request(time_request, timeout=5.0).data.read())[10]
    return time.ctime(now - EPOCH_START)
179728
def last_update_time(self) -> float:
        """"""
        stdout = self.stdout_interceptor
        stderr = self.stderr_interceptor

        return max([
            self._last_update_time,
            stdout.last_write_time if stdout else 0,
            stderr.last_write_time if stderr else 0,
        ])
521178
def date(self):
        ''' 
        '''
        utcnow = datetime.utcnow()
        return (utcnow + timedelta(hours=self.time_zone)).date()
643540
def _last_values(self):
        
        if not self.session.get('last_request_uri'):
            self.session.last_request_uri = None
        self.session.last_request_at = self.session.get('last_request_at', 0)
948260
def date(self):
        """"""
        if self.commit_time:
            return datetime.utcfromtimestamp(self.commit_time)
        else:
            return datetime.now()
387007
def now_date(str=False):
    """"""
    if str:
        return datetime.datetime.now().strftime("%Y-%m-%d")
    return datetime.date.today()
604978
def get_session_value(self, name, default=None):
        """"""

        value = self.redis().hget(self._session_key, name) or default
        self._update_session_expiration()
        return value
453593
def get_nanopubstore_start_dt(url: str):
    """"""

    hostname = urllib.parse.urlsplit(url)[1]

    start_dates_doc = state_mgmt.get(start_dates_doc_key)
    if start_dates_doc and start_dates_doc.get("start_dates"):
        date = [
            dt["start_dt"]
            for dt in start_dates_doc["start_dates"]
            if dt["nanopubstore"] == hostname
        ]
        log.info(f"Selected start_dt: {date}  len: {len(date)}")
        if len(date) == 1:
            return date[0]

    return "1900-01-01T00:00:00.000Z"
1199051
def date_range(self):
        """"""
        try:
            days = int(self.days)
        except ValueError:
            exit_after_echo(QUERY_DAYS_INVALID)

        if days < 1:
            exit_after_echo(QUERY_DAYS_INVALID)
        start = datetime.today()
        end = start + timedelta(days=days)
        return (
            datetime.strftime(start, '%Y-%m-%d'),
            datetime.strftime(end, '%Y-%m-%d')
        )
499127
def _session_start(self):
        
        return self._session_class(self._session_id,
                                   self._session_duration,
                                   self._session_settings)
735313
def date_local(self) -> datetime:
        """"""
        return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"])