[JIRA] Created: (DSY-577) Date Fields skip a day when set with daisy-api running on different system.

View: New views
4 Messages — Rating Filter:   Alert me  

[JIRA] Created: (DSY-577) Date Fields skip a day when set with daisy-api running on different system.

by JIRA issues@cocoondev.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Date Fields skip a day when set with daisy-api running on different system.
---------------------------------------------------------------------------

         Key: DSY-577
         URL: http://issues.cocoondev.org//browse/DSY-577
     Project: Daisy
        Type: Bug
  Components: Repository  
    Versions: 2.1, 2.0.1    
 Reporter: Marc Portier


When setting fields of type 'date' (not datetime) we experience strange offsets between dates entered, and retrieved again after save: some saved days appear to be shifted to the previous day (and some don't!)

Since this only happens when client and server VM are running on different systems (OS's) we are lead to believe that this is caused by

Some initial investigation showed that this is actually happening:

[1] document creation

* user enters date 12/04/1976
* this is put into a Java Date object that sets the time to midnight in the local timezone: e.g. 15/04/1976 00:00 GMT+2
* during save this is sent in the XML file over as 1976-04-15+02:00

* on the server this is received and converted to the relevant time-spot in the local timezone (assuming GMT+1) this becomes: 14/04/1976 23:00 GMT+1
* the time-fragment is ignored here and 14-04-1976 is what is actually being stored


[2] document retrieval

* the same document is retrieved from the server and the stored date gets put in a Java Date object with time to midnight in the local timezone: 14/04/1976 00:00 GMT+1
* send over in the XML as 1976-04-14+01:00
* and converted eventually at the client' side into the equivalent on the local timezone: 14/04/1976 01:00 GMT+1

displayed to the user this gives: 14/04/1976 one day earlier then the entered 15/04/1976.




--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.cocoondev.org//secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/site/services/daisy/daisysupport.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

[JIRA] Commented: (DSY-577) Date Fields skip a day when set with daisy-api running on different system.

by JIRA issues@cocoondev.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.cocoondev.org//browse/DSY-577?page=comments#action_13461 ]

Bart Van den Abeele commented on DSY-577:
-----------------------------------------

This only happens when 2 systems have a different TimeZone.  Our problem occured between systems that had Europe/Paris (the client) and Europe/Brussels (server) as timezone.  De default timezone on a windowssystem is Europe/Paris for belgium an we assign Europe/Brussels to our linux-servers.  There are a few dates on wich this problem occures :

van = from (inclusive)
tot = till (exclusve)

sun.util.calendar.ZoneInfo[id="Europe/Brussels",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Brussels,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
sun.util.calendar.ZoneInfo[id="Europe/Paris",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
SURE-TEST-SAMPLE:
Thu Mar 13 00:00:00 CET 1902
DATES:
van : Tue Jan 02 00:00:00 CET 1900 tot : Sat Mar 11 00:00:00 CET 1911
van : Sun Oct 05 00:00:00 CEST 1919 tot : Mon Oct 06 00:00:00 CET 1919
van : Sun Apr 21 00:00:00 CEST 1929 tot : Mon Apr 22 00:00:00 CEST 1929
van : Sun Apr 13 00:00:00 CEST 1930 tot : Mon Apr 14 00:00:00 CEST 1930
van : Sun Apr 19 00:00:00 CEST 1931 tot : Mon Apr 20 00:00:00 CEST 1931
van : Sun Apr 03 00:00:00 CEST 1932 tot : Mon Apr 04 00:00:00 CEST 1932
van : Sun Mar 26 00:00:00 CEST 1933 tot : Mon Mar 27 00:00:00 CEST 1933
van : Sun Apr 08 00:00:00 CEST 1934 tot : Mon Apr 09 00:00:00 CEST 1934
van : Sun Mar 31 00:00:00 CEST 1935 tot : Mon Apr 01 00:00:00 CEST 1935
van : Sun Apr 19 00:00:00 CEST 1936 tot : Mon Apr 20 00:00:00 CEST 1936
van : Sun Apr 04 00:00:00 CEST 1937 tot : Mon Apr 05 00:00:00 CEST 1937
van : Sun Mar 27 00:00:00 CEST 1938 tot : Mon Mar 28 00:00:00 CEST 1938
van : Sun Apr 16 00:00:00 CEST 1939 tot : Mon Apr 17 00:00:00 CEST 1939
van : Mon Sep 18 00:00:00 CEST 1944 tot : Sun Oct 08 00:00:00 CEST 1944
van : Mon Mar 29 00:00:00 CEST 1976 tot : Sun Sep 26 00:00:00 CET 1976


code :

package date;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;


public class TestDate
{
     public static void main(String[] args)
   {
       System.out.println(TimeZone.getTimeZone("Europe/Brussels"));
       System.out.println(TimeZone.getTimeZone("Europe/Paris"));
             Calendar brussels = Calendar.getInstance(TimeZone.getTimeZone("Europe/Brussels"));
       Calendar paris = Calendar.getInstance(TimeZone.getTimeZone("Europe/Paris"));

       System.out.println("SURE-TEST-SAMPLE:");
             paris.setTime(new Date(02,02,13));
       brussels.setTimeInMillis(brussels.getTime().getTime());
             if ( brussels.get(Calendar.DAY_OF_YEAR) != paris.get(Calendar.DAY_OF_YEAR ))
       {
           System.out.println(paris.getTime());
       }
             System.out.println("DATES:");
       Date van = null;                    for (int year = 1800 ; year < 2020 ; year ++)
       {                paris.clear();
           paris.set(year, 0, 1, 0, 0, 0);                                for (int day = 1 ; day < 365 ; day ++ )
           {
               paris.set(Calendar.DAY_OF_YEAR, day);
               brussels.setTime(paris.getTime());
                             if ( brussels.get(Calendar.DAY_OF_YEAR) != paris.get(Calendar.DAY_OF_YEAR ))
               {
                   if (van == null)
                   {
                       van = paris.getTime();
                       System.out.print("van : " + paris.getTime());                      }                                  }
               else
               {
                   if (van != null)
                   {
                       System.out.println(" tot : " + paris.getTime());
                       van = null;                      }                                  }                       }
       }
         }

}

> Date Fields skip a day when set with daisy-api running on different system.
> ---------------------------------------------------------------------------
>
>          Key: DSY-577
>          URL: http://issues.cocoondev.org//browse/DSY-577
>      Project: Daisy
>         Type: Bug
>   Components: Repository
>     Versions: 2.1, 2.0.1
>     Reporter: Marc Portier

>
> When setting fields of type 'date' (not datetime) we experience strange offsets between dates entered, and retrieved again after save: some saved days appear to be shifted to the previous day (and some don't!)
> Since this only happens when client and server VM are running on different systems (OS's) we are lead to believe that this is caused by
> Some initial investigation showed that this is actually happening:
> [1] document creation
> * user enters date 12/04/1976
> * this is put into a Java Date object that sets the time to midnight in the local timezone: e.g. 15/04/1976 00:00 GMT+2
> * during save this is sent in the XML file over as 1976-04-15+02:00
> * on the server this is received and converted to the relevant time-spot in the local timezone (assuming GMT+1) this becomes: 14/04/1976 23:00 GMT+1
> * the time-fragment is ignored here and 14-04-1976 is what is actually being stored
> [2] document retrieval
> * the same document is retrieved from the server and the stored date gets put in a Java Date object with time to midnight in the local timezone: 14/04/1976 00:00 GMT+1
> * send over in the XML as 1976-04-14+01:00
> * and converted eventually at the client' side into the equivalent on the local timezone: 14/04/1976 01:00 GMT+1
> displayed to the user this gives: 14/04/1976 one day earlier then the entered 15/04/1976.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.cocoondev.org//secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/site/services/daisy/daisysupport.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

[JIRA] Commented: (DSY-577) Date Fields skip a day when set with daisy-api running on different system.

by JIRA issues@cocoondev.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    [ http://issues.cocoondev.org//browse/DSY-577?page=comments#action_13462 ]

Marc Portier commented on DSY-577:
----------------------------------

I investigated further and found a way to make the Daisy API resilient towards different timezones being active at client and server sides of the API.

The point is that pure date values should be serialized into the XML format without both the timefragment *and* the timezone-indication.
(currently we only succesfully seem to reset the time-fragment, but fail at clearing the timezone)


So we should not have:

    <field typeId="14">
      <date>2007-11-14+01:00</date>
    </field>

but rather:

  <field typeId="14" xmlns="http://outerx.org/daisy/1.0">
    <date>2007-11-14</date>
  </field>


The immediate reflex that such should be the responsibility of xmlbeans correctly serializing data for a declared xs:date element seems to be put aside by a similar mentioning on the xmlbeans jira:
https://issues.apache.org/jira/browse/XMLBEANS-343

Inspired by the discussion there the more solid solution seems to be to fix our
org.outerj.daisy.repository.FieldHelper#DATE_DISTINCT_SETTER

@line 186 we should insert
    calendar.clear(Calendar.ZONE_OFFSET);

to force the desired time-zone free serialization format for date fields.

Equally on the getter side I would suggest

@line 326 to insert
    origValues[i].clear(Calendar.ZONE_OFFSET);



> Date Fields skip a day when set with daisy-api running on different system.
> ---------------------------------------------------------------------------
>
>          Key: DSY-577
>          URL: http://issues.cocoondev.org//browse/DSY-577
>      Project: Daisy
>         Type: Bug
>   Components: Repository
>     Versions: 2.1, 2.0.1
>     Reporter: Marc Portier

>
> When setting fields of type 'date' (not datetime) we experience strange offsets between dates entered, and retrieved again after save: some saved days appear to be shifted to the previous day (and some don't!)
> Since this only happens when client and server VM are running on different systems (OS's) we are lead to believe that this is caused by
> Some initial investigation showed that this is actually happening:
> [1] document creation
> * user enters date 12/04/1976
> * this is put into a Java Date object that sets the time to midnight in the local timezone: e.g. 15/04/1976 00:00 GMT+2
> * during save this is sent in the XML file over as 1976-04-15+02:00
> * on the server this is received and converted to the relevant time-spot in the local timezone (assuming GMT+1) this becomes: 14/04/1976 23:00 GMT+1
> * the time-fragment is ignored here and 14-04-1976 is what is actually being stored
> [2] document retrieval
> * the same document is retrieved from the server and the stored date gets put in a Java Date object with time to midnight in the local timezone: 14/04/1976 00:00 GMT+1
> * send over in the XML as 1976-04-14+01:00
> * and converted eventually at the client' side into the equivalent on the local timezone: 14/04/1976 01:00 GMT+1
> displayed to the user this gives: 14/04/1976 one day earlier then the entered 15/04/1976.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.cocoondev.org//secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/site/services/daisy/daisysupport.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

[JIRA] Closed: (DSY-577) Date Fields skip a day when set with daisy-api running on different system.

by JIRA issues@cocoondev.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

     [ http://issues.cocoondev.org//browse/DSY-577?page=all ]
     
Marc Portier closed DSY-577:
----------------------------

    Fix Version: 2.4
     Resolution: Fixed
      Assign To: Marc Portier

Fixed in revision 5306
http://svn.daisycms.org/viewsvn/daisy?view=revision&revision=5306

> Date Fields skip a day when set with daisy-api running on different system.
> ---------------------------------------------------------------------------
>
>          Key: DSY-577
>          URL: http://issues.cocoondev.org//browse/DSY-577
>      Project: Daisy
>         Type: Bug
>   Components: Repository
>     Versions: 2.1, 2.0.1
>     Reporter: Marc Portier
>     Assignee: Marc Portier
>      Fix For: 2.4

>
> When setting fields of type 'date' (not datetime) we experience strange offsets between dates entered, and retrieved again after save: some saved days appear to be shifted to the previous day (and some don't!)
> Since this only happens when client and server VM are running on different systems (OS's) we are lead to believe that this is caused by
> Some initial investigation showed that this is actually happening:
> [1] document creation
> * user enters date 12/04/1976
> * this is put into a Java Date object that sets the time to midnight in the local timezone: e.g. 15/04/1976 00:00 GMT+2
> * during save this is sent in the XML file over as 1976-04-15+02:00
> * on the server this is received and converted to the relevant time-spot in the local timezone (assuming GMT+1) this becomes: 14/04/1976 23:00 GMT+1
> * the time-fragment is ignored here and 14-04-1976 is what is actually being stored
> [2] document retrieval
> * the same document is retrieved from the server and the stored date gets put in a Java Date object with time to midnight in the local timezone: 14/04/1976 00:00 GMT+1
> * send over in the XML as 1976-04-14+01:00
> * and converted eventually at the client' side into the equivalent on the local timezone: 14/04/1976 01:00 GMT+1
> displayed to the user this gives: 14/04/1976 one day earlier then the entered 15/04/1976.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.cocoondev.org//secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy