Exemplo n.º 1
0
    def testValidationWithAlternativeCalendar(self):
        """ Test validation with calendar-override """

        assertEqual = self.assertEqual

        # Test default=Gregorian, override=Persian
        current.calendar = S3Calendar("Gregorian")
        validate = IS_UTC_DATE(calendar="Persian")

        dtstr = "1390-08-28"
        value, error = validate(dtstr)
        assertEqual(error, None)
        assertEqual(value, datetime.date(2011, 11, 19))

        dtstr_ = validate.formatter(value)
        assertEqual(dtstr_, dtstr)

        # Test default=Persian, override=Gregorian
        current.calendar = S3Calendar("Persian")
        validate = IS_UTC_DATE(calendar="Gregorian")

        dtstr = "2011-11-19"
        value, error = validate(dtstr)
        assertEqual(error, None)
        assertEqual(value, datetime.date(2011, 11, 19))

        dtstr_ = validate.formatter(value)
        assertEqual(dtstr_, dtstr)
Exemplo n.º 2
0
    def setUp(self):

        settings = current.deployment_settings

        # Set default calendar to Gregorian
        self.calendar = current.calendar
        current.calendar = S3Calendar("Gregorian")

        # Make sure date format is standard
        self.date_format = settings.get_L10n_date_format()
        settings.L10n.date_format = "%Y-%m-%d"

        # Set timezone to UTC
        session = current.session
        self.utc_offset = session.s3.utc_offset
        session.s3.utc_offset = 0
Exemplo n.º 3
0
    def setUp(self):

        settings = current.deployment_settings

        # Make sure date+time formats are standard
        self.date_format = settings.get_L10n_date_format()
        self.time_format = settings.get_L10n_time_format()
        settings.L10n.date_format = "%Y-%m-%d"
        settings.L10n.time_format = "%H:%M:%S"

        # Set timezone to UTC
        self.tzinfo = current.response.s3.tzinfo
        current.response.s3.tzinfo = S3DefaultTZ(0)

        # Set calendar to Gregorian
        self.calendar = current.calendar
        current.calendar = S3Calendar("Gregorian")
Exemplo n.º 4
0
    def setUp(self):

        settings = current.deployment_settings

        # Make sure date+time formats are standard
        self.date_format = settings.get_L10n_date_format()
        self.time_format = settings.get_L10n_time_format()
        settings.L10n.date_format = "%Y-%m-%d"
        settings.L10n.time_format = "%H:%M:%S"

        # Set timezone to UTC
        session = current.session
        self.utc_offset = session.s3.utc_offset
        session.s3.utc_offset = 0

        # Set calendar to Gregorian
        self.calendar = current.calendar
        current.calendar = S3Calendar("Gregorian")