Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom Date Item formats

    Are there any samples of custom date item formats that you may be able to provide? Since the DateTimeFormat is quite limited and does not even have a format we can use that shows month/day as a word instead of number except for the toString.

    We are looking into providing support for as many formats as possible but this would mean writing the code to handle all types of scenarios (for input formatting).
    Last edited by acarur01; 4 Feb 2011, 11:45.

    #2
    Allowing month/day words as inputs requires a pretty deep implementation if you plan to support internationalization. We don't have a sample of this kind.

    Comment


      #3
      You are right,browser-side support for internationalization is limited so unfortunately we are just dealing with custom formats as read-only values which we've processed in Java using SimpleDateFormat.

      But back to the supported formats, what about MM/DD/yy, or something like it? All the supported formats display the year in full form. I suppose yy wouldn't work if 1901 is the year value but some applications wouldn't have any use for a date so far back.

      Comment


        #4
        2 digit year input is supported, and it's interpretation as 20xx vs 19xx is controlled by the centuryThreshold setting on DateItem.

        Comment


          #5
          Ok thanks.

          I had a question about using a custom displayFormat. I want to provide a function and within this function I'd like to get a hold of my date item. Is this possible? I tried using "this" and it gives me the date object value, not the date item.

          Comment


            #6
            The only way to get hold of a DateItem within a custom data formatter would be to define the data formatter function in a place where the DateItem is in scope:

            Code:
            var dateItem = (some expression that returns the DateItem);
            var myFormatter = function () {
                if (dateItem.someProperty) { ... }
            }

            Comment


              #7
              I just tried setting a custom inputFormat, everything is fine until I return the value. Then I get this error: _1.toShortDate is not a function
              http://localhost:8080/cwf/isomorphic/system/modules/ISC_Forms.js
              Line 2340


              Any ideas? If it's not clear, I will try to get a standalone sample. I've also provided a custom display format which basically formats the date value properly and returns a formatted string.

              Code:
                  convertInputToDate: function(string, format){
                         var d =@com.conceptwave.gwt.client.Velocity::convertInputToDate(Ljava/lang/String;Ljava/lang/String;)(string, format);
                         
                         var newDate = new Date();
                         newDate.setTime(d);
                   return newDate;  
                   
                  }

              Comment


                #8
                Oh. Just tried returning the formatted string and it works. Not sure I understand..inputFormat is supposed to return a date value no?

                Comment


                  #9
                  You should be returning a date. You appear to be in JSNI and the problem is that you are using new Date() instead of $wnd.Date() so you are creating the Date instance in the wrong frame.

                  Comment


                    #10
                    Ah, yes. Sorry about that - works now.

                    Comment

                    Working...
                    X