Topic
  • 3 replies
  • Latest Post - ‏2014-04-03T16:18:55Z by SGreen
MyDeveloerWorks
MyDeveloerWorks
41 Posts

Pinned topic date/time picker control instances

‏2014-04-01T09:57:56Z |

Hello dxl Community,

This is probably the worst day of the year to be raising issues on the Date but here goes:

The Date DB object is exhibiting inconsistent behaviour:

DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
Date init = dateAndTime(today)   
DBE oDateDBE1 = date(TestCaseHistoryDB, 30,init, true)
DBE oDateDBE2 = date(TestCaseHistoryDB, 30,init, true)
 
 
void makeTestCaseHistory(DB winDB) {
  
 
    Date oDate = get(oDateDBE1)
    Date oDate2 = get(oDateDBE2)
    string sDate = stringOf(oDate)
    string sDate2 = stringOf(oDate2)
    print oDate  "\t"
    print oDate2  "\t"
 
 
    print "\n"
 
 
 
}
apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
realize(TestCaseHistoryDB)
show(TestCaseHistoryDB)

 

I was playing around with selecting dates. On the fourth selection, the date format changes for some unknown reason.

01/04/14 11:51:21 01/04/14 11:51:21   // press go
02/04/14 11:51:21 01/04/14 11:51:21  // select a different date/ press go
02/04/14 11:51:21 03/04/14 11:51:21  // repeat for 3 April
02/04/14 11:51:21 04/30/14 11:51:21   ///  Change the date date to April 30. sudden change of format! 

 

The behavioiur is the same if you force formats (with StringOf, local,etc). What is causing this format jump?

  • SGreen
    SGreen
    2 Posts

    Re: date/time picker control instances

    ‏2014-04-01T18:34:52Z  

    There is a problem here in the handling of dates which include a time component. It has been raised internally as a defect.

    A possible workaround would involve splitting the time and date components into separate DBEs. E.g. in code such as the following:

    "

    DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
    //Date init = dateAndTime(today)
    Date init = today
    DBE oDateDBE1 = date(TestCaseHistoryDB, 30, init, true)
    DBE timeField = field (TestCaseHistoryDB, "Time : ", "00:00:00", 25)

    void makeTestCaseHistory(DB winDB) {

        Date oDate = get(oDateDBE1)
        Date oDate2 = dateOnly oDate

        string sDate = stringOf(oDate)
        string sTime = get timeField
        print sDate " " sTime "\n"
    }

    apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
    realize(TestCaseHistoryDB)
    show(TestCaseHistoryDB)

    "

    It would be good to add verification of the time value, as it currently stands any string will be accepted.

  • MyDeveloerWorks
    MyDeveloerWorks
    41 Posts

    Re: date/time picker control instances

    ‏2014-04-02T13:26:15Z  
    • SGreen
    • ‏2014-04-01T18:34:52Z

    There is a problem here in the handling of dates which include a time component. It has been raised internally as a defect.

    A possible workaround would involve splitting the time and date components into separate DBEs. E.g. in code such as the following:

    "

    DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
    //Date init = dateAndTime(today)
    Date init = today
    DBE oDateDBE1 = date(TestCaseHistoryDB, 30, init, true)
    DBE timeField = field (TestCaseHistoryDB, "Time : ", "00:00:00", 25)

    void makeTestCaseHistory(DB winDB) {

        Date oDate = get(oDateDBE1)
        Date oDate2 = dateOnly oDate

        string sDate = stringOf(oDate)
        string sTime = get timeField
        print sDate " " sTime "\n"
    }

    apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
    realize(TestCaseHistoryDB)
    show(TestCaseHistoryDB)

    "

    It would be good to add verification of the time value, as it currently stands any string will be accepted.

    I can actually leave out the time element altogether for my purposes.

    However, there are two problems with this code

    When you press the button "Go" you get:

    (here is the error msg translated from Spanish to English))

    -RE-540, <Line:7> Format or value incorrect, the date (Wednesday, 02  Abril  2014)

    It only works if the commented out line 

    Date init = dateAndTime(today) is used

    Secondly the variable "oDate2" is not used. 

  • SGreen
    SGreen
    2 Posts

    Re: date/time picker control instances

    ‏2014-04-03T16:18:55Z  

    I can actually leave out the time element altogether for my purposes.

    However, there are two problems with this code

    When you press the button "Go" you get:

    (here is the error msg translated from Spanish to English))

    -RE-540, <Line:7> Format or value incorrect, the date (Wednesday, 02  Abril  2014)

    It only works if the commented out line 

    Date init = dateAndTime(today) is used

    Secondly the variable "oDate2" is not used. 

    I wasn't seeing this due to date format settings on my machine, and changing them is one possible solution.

    However, if the value is retrieved from the DBE as a string, it is more robust to different date formats.

    So can you try using something like "string sDate = get(oDateDBE1)".