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


Python DateTime.hour方法代码示例

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


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

示例1: testValidationRequiredSplitDate

# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import hour [as 别名]
 def testValidationRequiredSplitDate(self):
     s1 = getattr(self, 's1')
     sdq1 = getattr(s1, 'sdq1')
     sdq1.setRequired(True)
     now = DateTime()
     now_value = str(now.year()) + '/' + str(now.month()) + '/' + str(now.day()) + ' ' + str(now.hour()) + ':' + str(now.minute()) + ':00 GMT'
     self.layer['request'].form['sdq1_ampm'] = ''
     self.layer['request'].form['sdq1_day'] = str(now.day())
     self.layer['request'].form['sdq1_hour'] = str(now.hour())
     self.layer['request'].form['sdq1_minute'] = str(now.minute())
     self.layer['request'].form['sdq1_month'] = str(now.month())
     self.layer['request'].form['sdq1_year'] = str(now.year())
     dummy_controller_state = ControllerState(
                                 id='survey_view',
                                 context=s1,
                                 button='submit',
                                 status='success',
                                 errors={},
                                 next_action=None,)
     controller = self.portal.portal_form_controller
     controller_state = controller.validate(dummy_controller_state, self.layer['request'], ['validate_survey',])
     assert controller_state.getErrors() == {}, "Validation error raised: %s" % controller_state.getErrors()
     userid = s1.getSurveyId()
     assert userid == "test_user_1_", "Not default test user"
     questions = s1.getQuestions()
     for question in questions:
         if question.portal_type == 'Survey Date Question':
             assert question.getAnswerFor(userid) == now_value, "Answer not saved correctly: %s" % question.getAnswerFor(userid)
开发者ID:fourdigits,项目名称:Products.PloneSurvey,代码行数:30,代码来源:testDateQuestion.py


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