当前位置: 首页>>代码示例>>Python>>正文


Python DateTime.second方法代码示例

本文整理汇总了Python中DateTime.DateTime.second方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.second方法的具体用法?Python DateTime.second怎么用?Python DateTime.second使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTime.DateTime的用法示例。


在下文中一共展示了DateTime.second方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _dt_setter

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
    def _dt_setter(self, fieldtoset, value, **kwargs):
        # Always set the date in UTC, saving the timezone in another field.
        # But since the timezone value isn't known at the time of saving the
        # form, we have to save it timezone-naive first and let
        # timezone_handler convert it to the target zone afterwards.

        # Note: The name of the first parameter shouldn't be field, because
        # it's already in kwargs in some case.

        if not isinstance(value, DateTime): value = DateTime(value)

        # Get microseconds from seconds, which is a floating value. Round it
        # up, to bypass precision errors.
        micro = int(round(value.second()%1 * 1000000))

        value = DateTime('%04d-%02d-%02dT%02d:%02d:%02d%sZ' % (
                    value.year(),
                    value.month(),
                    value.day(),
                    value.hour(),
                    value.minute(),
                    value.second(),
                    micro and '.%s' % micro or ''
                    )
                )
        self.getField(fieldtoset).set(self, value, **kwargs)
开发者ID:seanupton,项目名称:plone.app.event,代码行数:28,代码来源:content.py

示例2: testRFC822

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
    def testRFC822(self):
        # rfc822 conversion
        dt = DateTime('2002-05-02T08:00:00+00:00')
        self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 +0000')

        dt = DateTime('2002-05-02T08:00:00+02:00')
        self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 +0200')

        dt = DateTime('2002-05-02T08:00:00-02:00')
        self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 -0200')

        # Checking that conversion from local time is working.
        dt = DateTime()
        dts = dt.rfc822().split(' ')
        times = dts[4].split(':')
        _isDST = time.localtime(time.time())[8]
        if _isDST:
            offset = time.altzone
        else:
            offset = time.timezone
        self.assertEqual(dts[0], dt.aDay() + ',')
        self.assertEqual(int(dts[1]), dt.day())
        self.assertEqual(dts[2], dt.aMonth())
        self.assertEqual(int(dts[3]), dt.year())
        self.assertEqual(int(times[0]), dt.h_24())
        self.assertEqual(int(times[1]), dt.minute())
        self.assertEqual(int(times[2]), int(dt.second()))
        self.assertEqual(dts[5], "%+03d%02d" % divmod((-offset / 60), 60))
开发者ID:chitaranjan,项目名称:Uber-Food-Trucks,代码行数:30,代码来源:test_datetime.py

示例3: testTZ2

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
 def testTZ2(self):
     # Time zone manipulation test 2
     dt = DateTime()
     dt1 = dt.toZone('GMT')
     s = dt.second()
     s1 = dt1.second()
     self.assertEqual(s, s1, (dt, dt1, s, s1))
开发者ID:chitaranjan,项目名称:Uber-Food-Trucks,代码行数:9,代码来源:test_datetime.py

示例4: testConstructor7

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
 def testConstructor7(self):
     """Constructor from parts"""
     dt = DateTime()
     dt1 = DateTime(dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone())
     # Compare representations as it's the
     # only way to compare the dates to the same accuracy
     self.assertEqual(repr(dt), repr(dt1))
开发者ID:wpjunior,项目名称:proled,代码行数:9,代码来源:testDateTime.py

示例5: testSubtraction

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
 def testSubtraction(self):
     """Reconstruction of a DateTime from its parts, with subtraction"""
     dt = DateTime()
     dt1 = dt - 3.141592653
     dt2 = DateTime(dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second())
     dt3 = dt2 - 3.141592653
     self.assertEqual(dt1, dt3, (dt, dt1, dt2, dt3))
开发者ID:wpjunior,项目名称:proled,代码行数:9,代码来源:testDateTime.py

示例6: testSubtraction

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
 def testSubtraction(self):
     # Reconstruction of a DateTime from its parts, with subtraction
     # this also tests the accuracy of addition and reconstruction
     dt = DateTime()
     dt1 = dt - 3.141592653
     dt2 = DateTime(
         dt.year(),
         dt.month(),
         dt.day(),
         dt.hour(),
         dt.minute(),
         dt.second())
     dt3 = dt2 - 3.141592653
     self.assertEqual(dt1, dt3, (dt, dt1, dt2, dt3))
开发者ID:chitaranjan,项目名称:Uber-Food-Trucks,代码行数:16,代码来源:test_datetime.py

示例7: testConstructor3

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
 def testConstructor3(self):
     # Constructor from date/time string
     dt = DateTime()
     dt1s = '%d/%d/%d %d:%d:%f %s' % (
         dt.year(),
         dt.month(),
         dt.day(),
         dt.hour(),
         dt.minute(),
         dt.second(),
         dt.timezone())
     dt1 = DateTime(dt1s)
     # Compare representations as it's the
     # only way to compare the dates to the same accuracy
     self.assertEqual(repr(dt), repr(dt1))
开发者ID:chitaranjan,项目名称:Uber-Food-Trucks,代码行数:17,代码来源:test_datetime.py

示例8: fromLineFrom

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
    def fromLineFrom(self,email,date):
        """
        Generate a conformant mbox From line from email and date strings.

        (unless date is unparseable, in which case we omit that part)
        """
        # "email" is in fact a real name or zwiki username - adapt it
        email = re.sub(r'\s','',email) or 'unknown'
        try:
            d = DateTime(date)
            return 'From %s %s %s %d %02d:%02d:%02d %s %d\n' % (
                email,d.aDay(),d.aMonth(),d.day(),d.hour(),
                d.minute(),d.second(),d.timezone(),d.year())
        except (DateTimeSyntaxError,AttributeError,IndexError):
            return 'From %s\n' % email
开发者ID:eaudeweb,项目名称:EionetProducts,代码行数:17,代码来源:Comments.py

示例9: _dt_setter

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import second [as 别名]
    def _dt_setter(self, fieldtoset, value, **kwargs):
        # Always set the date in UTC, saving the timezone in another field.
        # But since the timezone value isn't known at the time of saving the
        # form, we have to save it timezone-naive first and let
        # timezone_handler convert it to the target zone afterwards.

        # Note: The name of the first parameter shouldn't be field, because
        # it's already in kwargs in some case.

        if not isinstance(value, DateTime): value = DateTime(value)
        value = DateTime('%04d-%02d-%02dT%02d:%02d:%02dZ' % (
                    value.year(),
                    value.month(),
                    value.day(),
                    value.hour(),
                    value.minute(),
                    value.second())
                )
        self.getField(fieldtoset).set(self, value, **kwargs)
开发者ID:mooballit,项目名称:plone.app.event,代码行数:21,代码来源:content.py


注:本文中的DateTime.DateTime.second方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。