Announcement

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

    Where are the default start and enddates for Date/DateTime formitem pickers set?

    I am now going to ask a probably silly question... When i create a formitem and click on the date icon, the min and max dates in the picker are jan 1, 1995 and dec 31, 2020.
    However, in your showcase and documentation it says 10 years in the past and 5 years in the future.

    I can of course change this with formItem.setEndDate, but i'm trying to understand why my default values are not your default values :)

    I can't see any defaults being changed in load_skin
    I have no call to setEndDate anywhere i can find. I've looked for references to 2020, "defaults" etc.
    I can't find any reference in my code to setDefaultProperties. of any sort.

    I am probably missing something stupid, any idea what?

    #2
    I did a super small separate test that only uses Tahoe and not our custom skin, see below.

    It prints "max: Sun Jan 01 12:00:00 GMT+100 1995, Thu Dec 31 12:00:00 GMT+100 2020"


    Code:
    public void onModuleLoad() {
    
        DynamicForm form = new DynamicForm();
        DateTimeItem item = new DateTimeItem("test", "Test");
        //item.setEndDate(new Date(2025-1900, 01,01));
        form.setItems(item);
        form.draw();
        GWT.log("max: " + item.getStartDate() + ", " + item.getEndDate());
    }

    Comment


      #3
      "item" isn't a valid FormItem instance - use form.getItem("test").getStart/EndDate()

      Comment


        #4
        Sure perhaps. It was just an example though, the issue is not the examplecode but that all formitems that we have with datetimeitems have intervals between years 1995-2000 right now.

        In your javadoc it says "The default value is January 1st, 10 years before the current year", but that's not what i'm experiencing, so i'm wondering where it's set.

        (if i change the logging to
        Code:
         
         GWT.log("max: " + ((DateTimeItem)form.getItem("test")).getStartDate() + ", " +  ((DateTimeItem) form.getItem("test")).getEndDate());
        It still prints the same value).


        I have fixed it in code by using DateItem.setDefaultProperties, but again, i'm really curious as to why your showcase and my code differs.

        Comment


          #5
          The Javadoc is correct, and you can see the documented behavior, as you noted, in the online samples.

          1995 hasn't been the default for quite a long time, and you haven't mentioned your product version - so perhaps you're on a very old version? Or a very old build of 12.0, perhaps?

          Comment


            #6
            Heh, well i'm on 6.0... BUT the build from 2020-03-06. Not changed in 6.0?

            Comment


              #7
              No, but we'll consider doing so.

              The framework defaults come from statics that (in recent versions) default to this year -10 and this year +5. But these are undocumented so, for now in 6.0, setting DateItem.startDate and endDate with setDefaultProperties is the right way.

              Comment


                #8
                OK, well fantastic, that explains it and i can again sleep at night. Thanks for your help!

                Comment

                Working...
                X