Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Wrong date returned nativeutils.onDatePickerFinished

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22061

    jrrobles79

    I have an odd error on onDatePickerFinished, Im getting the date with  -1 day of the selected date, example:

    if I select 2019-08-13 , the nativeUtils is getting 2019-08-12, this happen on iOS, and Android(including physical devices), this works like this? or Im getting something wrong:

     

        Connections {
            target: nativeUtils
            onDatePickerFinished: {
                var year = 0
                var month = 0
                var day = 0
    
                console.debug(date)
    
            }
    ..
    ...
    
    }

     

    Selected date:  13 – August – 2019

     

    console:

    qml: lun ago 12 19:00:00 2019 GMT-0500

    #22070

    jrrobles79

    No one else is having this issue? can some one validate this error?

    #22106

    Alex
    Felgo Team
    #22229

    jrrobles79

    Hello Alex, thank you for your answer, sorry to be late, but I was working on the backend of the app. Yes I still have the same issue, (I tested the snippet above, and still have the same issue)  I think it has to be with the Date component of the Javascript:

    https://stackoverflow.com/questions/7556591/is-the-javascript-date-object-always-one-day-off

     

    But I thinks is weird the nativeutils isn’t taking on account my device locale, I would think it should give the date Im selecting.

     

    ps. this is the full date Im getting:   if I select today (07 -Oct – 2019)

    <b>selected date:dom oct 6 19:00:00 2019 GMT-0500</b>

    #22231

    jrrobles79

    BTW,  I added the suggested function on the post on Stackoverflow, and now is working fine, but Im going to wait if there is some other way to fix this:

     

      onDatePickerFinished: {
    
                console.debug("selected date before fix:"+date)
                date =  fixDate(date)
                console.debug("selected date after fix:"+date)
    ..
    ..
    }
    
    
    function fixDate(doo){
    {
    
                return new Date( doo.getTime() + Math.abs(doo.getTimezoneOffset()*60000) )
        }
    }

     

    Selecting: 2019-10-07

    <b>selected date (before fix;):dom oct 6 19:00:00 2019 </b><b>GMT-0500</b>

    <b>selected date (after fix;):lun oct 7 00:00:00 2019 GMT-0500</b>

     

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded