'Test localized date/time in default error messages'

def testLocalizedErrorMessages(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    current.deployment_settings.L10n.date_format = '%d/%m/%Y'
    current.session.s3.utc_offset = (+ 3)
    mindt = datetime.date(2011, 11, 16)
    maxdt = datetime.date(2011, 11, 20)
    validate = IS_UTC_DATE(minimum=mindt)
    msg = validate.error_message
    assertEqual(validate.minimum, mindt)
    assertTrue((msg.find('16/11/2011') != (-1)))
    dtstr = '13/11/2011'
    (value, error) = validate(dtstr)
    assertEqual(value, dtstr)
    assertEqual(error, msg)
    validate = IS_UTC_DATE(maximum=maxdt)
    msg = validate.error_message
    assertEqual(validate.maximum, maxdt)
    assertTrue((msg.find('20/11/2011') != (-1)))
    validate = IS_UTC_DATE(minimum=mindt, format='%Y-%m-%d')
    msg = validate.error_message
    assertEqual(validate.minimum, mindt)
    assertTrue((msg.find('2011-11-16') != (-1)))
    validate = IS_UTC_DATE(maximum=maxdt, format='%Y-%m-%d')
    msg = validate.error_message
    assertEqual(validate.maximum, maxdt)
    assertTrue((msg.find('2011-11-20') != (-1)))
