MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-748

Client-side DateTimeRangeValidator does not handle differences in timezone

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.2-core
    • Fix Version/s: 1.0.5-core, 1.2.4-core
    • Component/s: Components
    • Labels:
      None

      Description

      Scenario: I'm using a DateTimeRangeValidator on an inputDate, with minimum bound to a Date, say, since today at midnight (Oct 1 2007 12:00:00 AM). The server is running in local time (Pacific/Los_Angeles). The client is running in America/New_York timezone.

      If client-side validation is disabled, the user can enter a string like "Oct 1 2007 12:00:01 AM" and that will submit successfully since the string is interpreted into the server's timezone and it is indeed greater than today's midnight.

      If client-side validation is enabled, the same string will fail. The error message is "Enter a date greater than or equal to Oct 1 2007 3:00:00 AM". This is because the client-side validator is interpreting the value in the local timezone, so "Oct 1 2007 12:00:01 AM EST". That is earlier than "Oct 1 2007 12:00:00 AM PDT", so it fails validation.

      The net result is, the values accepted are dependent on client-side validation being enabled, and whether the timezone adds/subtracts from the value so that it still falls within range.

        Activity

        Hide
        Yee-Wah Lee added a comment -

        Proposal : Send down min, max as Strings instead of millisecond Dates. Then, use the client-side converter to create the Date objects from the Strings. That way, the min/max/value will all be interpreted with the same client-converter pattern and timezone offset.

        Show
        Yee-Wah Lee added a comment - Proposal : Send down min, max as Strings instead of millisecond Dates. Then, use the client-side converter to create the Date objects from the Strings. That way, the min/max/value will all be interpreted with the same client-converter pattern and timezone offset.
        Hide
        Yee-Wah Lee added a comment -

        Patch which :

        • Sends down min/max for the DateTimeRangeValidator as strings
        • Uses client converter to recreate the strings
        • Adds a couple of timezone examples with DateTimeRangeValidator to clientConvert.jspx
        Show
        Yee-Wah Lee added a comment - Patch which : Sends down min/max for the DateTimeRangeValidator as strings Uses client converter to recreate the strings Adds a couple of timezone examples with DateTimeRangeValidator to clientConvert.jspx
        Hide
        Yee-Wah Lee added a comment -

        Updated patch, based on comments from Matthias Wessendorf

        • Cast the UIComponent into EditableValueHolder instead of ValueHolder, because that is what validators require.
        Show
        Yee-Wah Lee added a comment - Updated patch, based on comments from Matthias Wessendorf Cast the UIComponent into EditableValueHolder instead of ValueHolder, because that is what validators require.
        Hide
        Yee-Wah Lee added a comment -

        Added to patch:

        • Comments to chooseDate, validateDateTimeRange tagdoc for min/max attributes to maximize the date-time values where applicable.
        Show
        Yee-Wah Lee added a comment - Added to patch: Comments to chooseDate, validateDateTimeRange tagdoc for min/max attributes to maximize the date-time values where applicable.
        Hide
        Yee-Wah Lee added a comment -

        Added documentation

        Show
        Yee-Wah Lee added a comment - Added documentation

          People

          • Assignee:
            Matthias Weßendorf
            Reporter:
            Yee-Wah Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development