python类fromtimestamp()的实例源码

views.py 文件源码 项目:ahmia-site 作者: ahmia 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def get_context_data(self, **kwargs):
        """
        Get the context data to render the result page.
        """
        page = kwargs['page']
        length, results = self.object_list
        max_pages = int(math.ceil(float(length) / self.RESULTS_PER_PAGE))

        return {
            'page': page+1,
            'max_pages': max_pages,
            'result_begin': self.RESULTS_PER_PAGE * page,
            'result_end': self.RESULTS_PER_PAGE * (page + 1),
            'total_search_results': length,
            'query_string': kwargs['q'],
            'search_results': results,
            'search_time': kwargs['time'],
            'now': date.fromtimestamp(time.time())
        }
idatetime.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 46 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).

        fromtimestamp() may raise ValueError, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        See also utcfromtimestamp().
        """
base.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def DateFromTicks(self, secs):
        """
        Returns an object representing the date *secs* seconds after the
        epoch. For example:

        .. python::

            import time

            d = db.DateFromTicks(time.time())

        This method is equivalent to the module-level ``DateFromTicks()``
        method in an underlying DB API-compliant module.

        :Parameters:
            secs : int
                the seconds from the epoch

        :return: an object containing the date
        """
        date = date.fromtimestamp(secs)
        return self.__driver.get_import().Date(date.year, date.month, date.day)
base.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def Time(self, hour, minute, second):
        """
        Returns an object representing the specified time.

        This method is equivalent to the module-level ``Time()`` method in an
        underlying DB API-compliant module.

        :Parameters:
            hour
                the hour of the day
            minute
                the minute within the hour. 0 <= *minute* <= 59
            second
                the second within the minute. 0 <= *second* <= 59

        :return: an object containing the time
        """
        dt = datetime.fromtimestamp(secs)
        return self.__driver.get_import().Time(dt.hour, dt.minute, dt.second)
base.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def TimeFromTicks(self, secs):
        """
        Returns an object representing the time 'secs' seconds after the
        epoch. For example:

        .. python::

            import time

            d = db.TimeFromTicks(time.time())

        This method is equivalent to the module-level ``TimeFromTicks()``
        method in an underlying DB API-compliant module.

        :Parameters:
            secs : int
                the seconds from the epoch

        :return: an object containing the time
        """
        dt = datetime.fromtimestamp(secs)
        return self.__driver.get_import().Time(dt.hour, dt.minute, dt.second)
pytables.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def _unconvert_index(data, kind, encoding=None):
    kind = _ensure_decoded(kind)
    if kind == u('datetime64'):
        index = DatetimeIndex(data)
    elif kind == u('timedelta64'):
        index = TimedeltaIndex(data)
    elif kind == u('datetime'):
        index = np.asarray([datetime.fromtimestamp(v) for v in data],
                           dtype=object)
    elif kind == u('date'):
        try:
            index = np.asarray(
                [date.fromordinal(v) for v in data], dtype=object)
        except (ValueError):
            index = np.asarray(
                [date.fromtimestamp(v) for v in data], dtype=object)
    elif kind in (u('integer'), u('float')):
        index = np.asarray(data)
    elif kind in (u('string')):
        index = _unconvert_string_array(data, nan_rep=None, encoding=encoding)
    elif kind == u('object'):
        index = np.asarray(data[0])
    else:  # pragma: no cover
        raise ValueError('unrecognized index type %s' % kind)
    return index
BackupRestore.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 45 收藏 0 点赞 0 评论 0
def doBackup(self):
        configfile.save()
        if config.plugins.softwaremanager.epgcache.value:
            eEPGCache.getInstance().save()
        try:
            if not path.exists(self.backuppath):
                makedirs(self.backuppath)
            self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
            if path.exists(self.fullbackupfilename):
                dt = str(date.fromtimestamp(stat(self.fullbackupfilename).st_ctime))
                self.newfilename = self.backuppath + "/" + dt + '-' + self.backupfile
                if path.exists(self.newfilename):
                    remove(self.newfilename)
                rename(self.fullbackupfilename,self.newfilename)
            if self.finished_cb:
                self.session.openWithCallback(self.finished_cb, Console, title = _("Backup is running..."), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB,closeOnSuccess = True)
            else:
                self.session.open(Console, title = _("Backup is running..."), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB, closeOnSuccess = True)
        except OSError:
            if self.finished_cb:
                self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
            else:
                self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
idatetime.py 文件源码 项目:AskTanmay-NLQA-System- 作者: tanmayb123 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).

        fromtimestamp() may raise ValueError, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        See also utcfromtimestamp().
        """
idatetime.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).

        fromtimestamp() may raise ValueError, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        See also utcfromtimestamp().
        """
HelperFunctions.py 文件源码 项目:enigma2-plugins 作者: opendreambox 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def getFuzzyDay(t):
    d = localtime(t)
    nt = time()
    n = localtime()

    if d[:3] == n[:3]:
        # same day
        date = _("Today")
    elif dt_date.fromtimestamp(t) == dt_date.today() + dt_timedelta(days = 1):
        # next day
        date = _("Tomorrow")
    elif nt < t and (t - nt) < WEEKSECONDS:
        # same week
        date = WEEKDAYS[d.tm_wday]
    else:
        date = "%d.%d.%d" % (d.tm_mday, d.tm_mon, d.tm_year)

    return date

# used to let timer pixmaps blink in our lists
tvpvod.py 文件源码 项目:crossplatform_iptvplayer 作者: j00zek 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def listEPGItems(self, cItem):
        printDBG("TvpVod.listEPGItems")
        sts, data = self._getPage(cItem['url'], self.defaultParams)
        if not sts: return
        try:
            #date.fromtimestamp(item['release_date']['sec']).strftime('%H:%M')
            data = byteify(json.loads(data))
            data['items'].sort(key=lambda item: item['release_date_hour'])
            for item in data['items']:
                if not item.get('is_live', False): continue 
                title = str(item['title'])
                desc  = str(item['lead'])
                asset_id  = str(item['asset_id'])
                asset_id  = str(item['video_id'])
                icon  = self.getImageUrl(item)
                desc  = item['release_date_hour'] + ' - ' + item['broadcast_end_date_hour'] + '[/br]' + desc 
                self.addVideo({'title':title, 'url':'', 'object_id':asset_id, 'icon':icon, 'desc':desc})
            printDBG(data)
        except Exception:
            printExc()
BackupRestore.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def doBackup(self):
        configfile.save()
        if config.plugins.softwaremanager.epgcache.value:
            eEPGCache.getInstance().save()
        try:
            if (path.exists(self.backuppath) == False):
                makedirs(self.backuppath)
            self.backupdirs = ' '.join([sub("^/+", "", d) for d in config.plugins.configurationbackup.backupdirs.value])
            if path.exists(self.fullbackupfilename):
                dt = str(date.fromtimestamp(stat(self.fullbackupfilename).st_ctime))
                self.newfilename = self.backuppath + "/" + dt + '-' + self.backupfile
                if path.exists(self.newfilename):
                    remove(self.newfilename)
                rename(self.fullbackupfilename,self.newfilename)
            if self.finished_cb:
                self.session.openWithCallback(self.finished_cb, Console, title = _("Backup is running..."), cmdlist = ["tar -C / -czvf " + self.fullbackupfilename + " " + self.backupdirs], finishedCallback = self.backupFinishedCB,closeOnSuccess = True)
            else:
                self.session.open(Console, title = _("Backup is running..."), cmdlist = ["tar -C / -czvf " + self.fullbackupfilename + " " + self.backupdirs], finishedCallback = self.backupFinishedCB, closeOnSuccess = True)
        except OSError:
            if self.finished_cb:
                self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
            else:
                self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
time.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _x_format(self):
        """Return the value formatter for this graph"""
        def date_to_str(x):
            d = date.fromtimestamp(x)
            return self.x_value_formatter(d)
        return date_to_str
idatetime.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def today():
        """Return the current local time.

        This is equivalent to date.fromtimestamp(time.time())"""
idatetime.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp):
        """Return the local date from a POSIX timestamp (like time.time())

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C localtime() function. It's common
        for this to be restricted to years from 1970 through 2038. Note that
        on non-POSIX systems that include leap seconds in their notion of a
        timestamp, leap seconds are ignored by fromtimestamp().
        """
idatetime.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 51 收藏 0 点赞 0 评论 0
def today():
        """Return the current local datetime, with tzinfo None.

        This is equivalent to datetime.fromtimestamp(time.time()).
        See also now(), fromtimestamp().
        """
idatetime.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).

        fromtimestamp() may raise ValueError, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        See also utcfromtimestamp().
        """
idatetime.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def utcfromtimestamp(timestamp):
        """Return the UTC datetime from the POSIX timestamp with tzinfo None.

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C gmtime() function. It's common for
        this to be restricted to years in 1970 through 2038.

        See also fromtimestamp().
        """
appcachepoison.py 文件源码 项目:mitmfnz 作者: dropnz 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def cacheForFuture(self, headers):
        ten_years = 315569260
        headers.setRawHeaders("Cache-Control",["max-age={}".format(ten_years)])
        headers.setRawHeaders("Last-Modified",["Mon, 29 Jun 1998 02:28:12 GMT"]) # it was modifed long ago, so is most likely fresh
        in_ten_years = date.fromtimestamp(time.time() + ten_years)
        headers.setRawHeaders("Expires",[in_ten_years.strftime("%a, %d %b %Y %H:%M:%S GMT")])
vnpy_data_source.py 文件源码 项目:rqalpha-mod-vnpy 作者: ricequant 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def available_data_range(self, frequency):
        if frequency != 'tick':
            raise NotImplementedError
        s = date.today()
        e = date.fromtimestamp(2147483647)
        return s, e
default_email.py 文件源码 项目:freezer-dr 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def notify_status(self, node, status):
        _template = 'info.jinja'
        if status == 'success':
            _template = 'user_success.jinja'
        elif status == 'error':
            _template = 'error.jinja'

        for tenant in node.get('tenants'):
            for user in tenant.get('users'):
                if 'email' in user:
                    subject = '[' + status + '] Evacuation Status'
                    template_vars = {
                        'name': user.get('name'),
                        'tenant': tenant.get('id'),
                        'instances': tenant.get('instances'),
                        'evacuation_time': date.fromtimestamp(time.time())
                    }
                    message = load_jinja_templates(self.templates_dir,
                                                   _template, template_vars)
                    self.send_email(self.notify_from, user.get('email'),
                                    subject, html_msg=message)
        # notify administrators
        subject = 'Host Evacuation status'
        _template = 'success.jinja'
        template_vars = {
            'host': node.get('host'),
            'tenants': node.get('tenants'),
            'instances': node.get('instances'),
            'hypervisor': node.get('details'),
            'evacuation_time': date.fromtimestamp(time.time())
        }
        message = load_jinja_templates(self.templates_dir, _template,
                                       template_vars)
        self.send_email(self.notify_from, self.notify_from, subject,
                        message, self.admin_list or None)
models.py 文件源码 项目:conditional 作者: ComputerScienceHouse 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, name, onfloor, room=None, missed=None):
        self.name = name
        today = date.fromtimestamp(time.time())
        self.eval_date = today + timedelta(weeks=10)
        self.onfloor_status = onfloor
        self.room_number = room
        self.signatures_missed = missed
datecolumn.py 文件源码 项目:clickhouse-driver 作者: mymarilyn 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def after_read_item(self, value):
        return date.fromtimestamp(value * self.offset)
appcachepoison.py 文件源码 项目:piSociEty 作者: paranoidninja 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def cacheForFuture(self, headers):
        ten_years = 315569260
        headers.setRawHeaders("Cache-Control",["max-age={}".format(ten_years)])
        headers.setRawHeaders("Last-Modified",["Mon, 29 Jun 1998 02:28:12 GMT"]) # it was modifed long ago, so is most likely fresh
        in_ten_years = date.fromtimestamp(time.time() + ten_years)
        headers.setRawHeaders("Expires",[in_ten_years.strftime("%a, %d %b %Y %H:%M:%S GMT")])
test_behavior.py 文件源码 项目:pendulum 作者: sdispater 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def test_fromtimestamp(self):
        self.assertEqual(
            date.fromtimestamp(0),
            Date.fromtimestamp(0)
        )
idatetime.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def today():
        """Return the current local time.

        This is equivalent to date.fromtimestamp(time.time())"""
idatetime.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def fromtimestamp(timestamp):
        """Return the local date from a POSIX timestamp (like time.time())

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C localtime() function. It's common
        for this to be restricted to years from 1970 through 2038. Note that
        on non-POSIX systems that include leap seconds in their notion of a
        timestamp, leap seconds are ignored by fromtimestamp().
        """
idatetime.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def today():
        """Return the current local datetime, with tzinfo None.

        This is equivalent to datetime.fromtimestamp(time.time()).
        See also now(), fromtimestamp().
        """
idatetime.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def utcfromtimestamp(timestamp):
        """Return the UTC datetime from the POSIX timestamp with tzinfo None.

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C gmtime() function. It's common for
        this to be restricted to years in 1970 through 2038.

        See also fromtimestamp().
        """
nepdate.py 文件源码 项目:nepalicalendar-py 作者: nepalicalendar 项目源码 文件源码 阅读 49 收藏 0 点赞 0 评论 0
def fromtimestamp(cls, timestamp):
        """ Returns a NepDate object created from timestamp """
        return NepDate.from_ad_date(date.fromtimestamp(timestamp))


问题


面经


文章

微信
公众号

扫码关注公众号