本文整理汇总了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)