當前位置: 首頁>>代碼示例>>Python>>正文


Python time.localtime方法代碼示例

本文整理匯總了Python中datetime.time.localtime方法的典型用法代碼示例。如果您正苦於以下問題:Python time.localtime方法的具體用法?Python time.localtime怎麽用?Python time.localtime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在datetime.time的用法示例。


在下文中一共展示了time.localtime方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fromtimestamp

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
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().
        """ 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:24,代碼來源:idatetime.py

示例2: fromtimestamp

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
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.

        .. seealso:: `utcfromtimestamp`.
        """ 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:24,代碼來源:idatetime.py

示例3: updateLog

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
def updateLog(self, event):
        """更新日誌"""
        # 獲取當前時間和日誌內容
        t = time.strftime('%H:%M:%S',time.localtime(time.time()))   
        log = event.dict_['log']                                    

        # 在表格最上方插入一行
        self.insertRow(0)              

        # 創建單元格
        cellTime = QtGui.QTableWidgetItem(t)    
        cellLog = QtGui.QTableWidgetItem(log)

        # 將單元格插入表格
        self.setItem(0, 0, cellTime)            
        self.setItem(0, 1, cellLog)


######################################################################## 
開發者ID:sunshinelover,項目名稱:chanlun,代碼行數:21,代碼來源:demoUi.py

示例4: test_fromtimestamp

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
def test_fromtimestamp(self):
        import time

        ts = time.time()
        expected = time.localtime(ts)
        got = self.theclass.fromtimestamp(ts)
        self.verify_field_equality(expected, got) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_datetime.py

示例5: timetuple

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
def timetuple():
        """Return a 9-element tuple of the form returned by time.localtime().

        The hours, minutes and seconds are 0, and the DST flag is -1.
        d.timetuple() is equivalent to
        (d.year, d.month, d.day, 0, 0, 0, d.weekday(), d.toordinal() -
        date(d.year, 1, 1).toordinal() + 1, -1)
        """ 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:10,代碼來源:idatetime.py

示例6: test_microsecond_rounding

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
def test_microsecond_rounding(self):
        for fts in [self.theclass.fromtimestamp,
                    self.theclass.utcfromtimestamp]:
            zero = fts(0)
            self.assertEqual(zero.second, 0)
            self.assertEqual(zero.microsecond, 0)
            one = fts(1e-6)
            try:
                minus_one = fts(-1e-6)
            except OSError:
                # localtime(-1) and gmtime(-1) is not supported on Windows
                pass
            else:
                self.assertEqual(minus_one.second, 59)
                self.assertEqual(minus_one.microsecond, 999999)

                t = fts(-1e-8)
                self.assertEqual(t, zero)
                t = fts(-9e-7)
                self.assertEqual(t, minus_one)
                t = fts(-1e-7)
                self.assertEqual(t, zero)
                t = fts(-1/2**7)
                self.assertEqual(t.second, 59)
                self.assertEqual(t.microsecond, 992188)

            t = fts(1e-7)
            self.assertEqual(t, zero)
            t = fts(9e-7)
            self.assertEqual(t, one)
            t = fts(0.99999949)
            self.assertEqual(t.second, 0)
            self.assertEqual(t.microsecond, 999999)
            t = fts(0.9999999)
            self.assertEqual(t.second, 1)
            self.assertEqual(t.microsecond, 0)
            t = fts(1/2**7)
            self.assertEqual(t.second, 0)
            self.assertEqual(t.microsecond, 7812) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:41,代碼來源:datetimetester.py

示例7: timetuple

# 需要導入模塊: from datetime import time [as 別名]
# 或者: from datetime.time import localtime [as 別名]
def timetuple():
        """Return a 9-element tuple of the form returned by `time.localtime`.

        The hours, minutes and seconds are 0, and the DST flag is -1.
        ``d.timetuple()`` is equivalent to
        ``(d.year, d.month, d.day, 0, 0, 0, d.weekday(), d.toordinal() -
        date(d.year, 1, 1).toordinal() + 1, -1)``
        """ 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:10,代碼來源:idatetime.py


注:本文中的datetime.time.localtime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。