Announcement

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

    DateRange.getEndDate does not include time?

    Hello, I'm using:
    Isomorphic SmartClient/SmartGWT Framework (v8.3p_2012-11-23/PowerEdition Deployment 2012-11-23)

    I am using a DateRangeItem where time of day is of importance.

    Here is the little form I created:
    Code:
    public class DateSelectionForm extends DynamicForm {
    	 DateRangeItem dateRangeItem = new DateRangeItem("orderDate", "Datumbereik");  
    	public DateSelectionForm(){
    		init();
    	}
    	
    	public void init(){
                 initDateRangeItem();  
                 setFields(dateRangeItem);
    	}
    	
    	private void initDateRangeItem() {
    		setDataSource(DataSource.get("Order_"));
    		dateRangeItem.setAllowRelativeDates(true);  
                    DateRange dateRange = new DateRange();  
                    dateRange.setRelativeStartDate(RelativeDate.TODAY);  
                    dateRange.setRelativeEndDate(RelativeDate.END_OF_TODAY);  
                    dateRangeItem.setValue(dateRange);
    	}
    	
    	public DateRangeItem getDateRangeItem(){
    		return dateRangeItem;
    	}
    	
    
    	public Date getStartDate(){
    		DateRange range = dateRangeItem.getValue();
    		return range.getStartDate();
    	}
    	
    	public Date getEndDate(){
    		DateRange range = dateRangeItem.getValue();
    		return range.getEndDate();
    	}
    }

    If I choose Today in both fields, it shows today's date, with 00:00 in the start date, and 23:59 in the enddate date picker (so far so good).

    However, if I call getEndDate() the time in the returned Date object is 00:00:00, so If the date would be 2012/12/31 23:59 (which is displayed correctly in the picker), a call to getEndDate() would give me 2012/12/31 00:00.

    Is this a bug? I am using the EUROPEAN date format, if that makes a difference.
    Last edited by Sytematic; 3 Dec 2012, 04:00.

    #2
    Attached is a screenshot (where 'Vandaag' means 'Today' in Dutch) showing that the date is indeed rendered correctly.
    Attached Files

    Comment


      #3
      What's the field type in your DataSource?

      If it's "date" this would be expected, because filtering ignores the time component. Use a "datetime" field instead.

      Comment


        #4
        Thanks for the hint, but it was datetime already.

        The field is defined as follows:
        Code:
        <field name="orderDate" type="datetime" required="false"> 
          <title>orderDate</title>  
          <validators></validators> 
        </field>
        Any other things that could be causing this?

        Comment


          #5
          There was a bug here - thanks for pointing this out. It's been fixed for 3.0p, 3.1p and 4.0d.

          Comment


            #6
            My Isomorphic SmartClient/SmartGWT version: 4.0p from 28-02-2014, Chrome Version: 30.0.1599.66, CentOS release 6.4.

            I'm using MiniDateRangeItem with time. The dialog doesn't pick up the hour and minute part, though, setting it always to default start and end time. Time is also not inlcuded when I use DateRangeItem with allowRelativeDates() set to true.

            My datasource:
            Code:
            DataSourceField createdField = new DataSourceDateTimeField(TIMESTAMP, translate("label.created"));
            Listgrid field definition:
            Code:
            createdListGridField.setFilterEditorProperties(new MiniDateRangeItem());
            I've checked the showcase example (http://www.smartclient.com/smartgwt/showcase/#form_controls_various) and can see that in there the time is also not updated in the MiniDateRangeItem or DateRangeItem examples.

            Comment


              #7
              Make sure you've specifically set the ListGridField's type to "datetime".

              Let us know if that solves it and we'll address the samples.

              Comment


                #8
                I set the type by:
                Code:
                listGridField.setType(ListGridFieldType.DATETIME);
                and the time I get is still always the default time, not the one specified in the form:

                Code:
                {\"fieldName\":\"ts\",\"operator\":\"greaterOrEqual\",\"value\":\"2014-03-02T23:00:00\"},
                {\"fieldName\":\"ts\",\"operator\":\"lessOrEqual\",\"value\":\"2014-03-31T22:59:59\"}]}]}]}"

                Comment


                  #9
                  Ok, we'll look into it - in the meantime, it should work if you set type "datetime" directly on the FormItem you provied for filterEditorProperties

                  Comment


                    #10
                    Hm, setting the type on the FormItem, as below, didn't solve the problem.

                    Code:
                    							
                    listGridField.setType(ListGridFieldType.DATETIME);
                    MiniDateRangeItem dateRangeItem = new MiniDateRangeItem();
                    dateRangeItem.setType("datetime");							
                    listGridField.setFilterEditorProperties(dateRangeItem);
                    Last edited by aznex; 3 Mar 2014, 05:11. Reason: formatting

                    Comment


                      #11
                      Please provide a standalone sample that shows the issue, including any datasources the sample needs (you can make clientOnly ones if need be)

                      Comment


                        #12
                        Hello Isomorhpic,

                        I'm attaching the samples.

                        When you open the Filter Editor for Created, you can see that you are not able to set hour or time and (also when using filter criteria with a server side), the time is always set to default (eg. 00:00:00) regardless of what hour/min you set.
                        Attached Files

                        Comment


                          #13
                          Your ListGridFields have the wrong names, so they aren't mapped to the DataSource. If you want to show custom titles, use the appropriate ListGridField constructor.

                          When you've fixed that, just setType(ListGridFieldType.DATETIME) and it will work - you don't need to setFilterEditorProperties() because the default for a datetime field is already to show a MiniDateRangeItem in the filterEditor.
                          Last edited by Isomorphic; 4 Mar 2014, 05:22.

                          Comment


                            #14
                            Hi Isomorphic,

                            The MiniDateRangeItem is indeed shown by default on the datetime listgrid field, as you say, but unfortunately, the time section is not included in the filter, just as in the json criteria I pasted before.

                            Comment


                              #15
                              Please, also check the showcase example how the time is not included in the date range:

                              http://www.smartclient.com/smartgwt/showcase/#form_controls_various

                              Pick Mini Date Range or Date Range and see how when you pick up time, it is not registered in the brackets to the right of the input field (the time is always 00:00).
                              Attached Files

                              Comment

                              Working...
                              X