'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.deployment_settings.L10n.time_format = '%I:%M    %p'
    current.session.s3.utc_offset = (+ 3)
    mindt = datetime.datetime(2011, 11, 19, 14, 0, 0)
    maxdt = datetime.datetime(2011, 11, 20, 22, 0, 0)
    validate = IS_UTC_DATETIME(minimum=mindt)
    msg = validate.error_message
    assertEqual(validate.minimum, mindt)
    assertTrue((msg.find('19/11/2011    05:00    PM') != (-1)))
    validate = IS_UTC_DATETIME(maximum=maxdt)
    msg = validate.error_message
    assertEqual(validate.maximum, maxdt)
    assertTrue((msg.find('21/11/2011    01:00    AM') != (-1)))
    validate = IS_UTC_DATETIME(minimum=mindt, format='%Y-%m-%d    %H:%M')
    msg = validate.error_message
    assertEqual(validate.minimum, mindt)
    assertTrue((msg.find('2011-11-19    17:00') != (-1)))
    validate = IS_UTC_DATETIME(maximum=maxdt, format='%Y-%m-%d    %H:%M')
    msg = validate.error_message
    assertEqual(validate.maximum, maxdt)
    assertTrue((msg.find('2011-11-21    01:00') != (-1)))
