Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 19
Registered: ‎06-26-2013
My Device: BlackBerry Z10
My Carrier: It's a test device without a SIM
Accepted Solution

Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

[ Edited ]

I am using a DateTimePicker to get the date/day of the week,etc picked by the user. Is there a straight-froward way of doing this without using C++?

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

[ Edited ]
Contributor
Posts: 19
Registered: ‎06-26-2013
My Device: BlackBerry Z10
My Carrier: It's a test device without a SIM

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

Okay so the user selects a date using DateTimePicker (id: datePicker) and then a button is clicked. I want to process the date selected in a javascript function on the button click. However when I try to use: var weekDay = datePicker.values.date().dayOfWeek(); I get an error saying datePicker.values.date isn't a function.
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

It should be:

 

 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

[ Edited ]

Sorry, I forget to attach the code :-)

var dateSelected = datePicker.value;
console.log("dateSelected=" + dateSelected);
var daywwek = dateSelected.getDay();
console.log("dayWeek=" + daywwek);

 

Contributor
Posts: 19
Registered: ‎06-26-2013
My Device: BlackBerry Z10
My Carrier: It's a test device without a SIM

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

[ Edited ]

Oh wow, thanks. Works like a charm. Smiley Happy

Contributor
Posts: 19
Registered: ‎06-26-2013
My Device: BlackBerry Z10
My Carrier: It's a test device without a SIM

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

Btw, were is the values.getDay() method documented? I couldn't find it on: https://developer.blackberry.com/cascades/reference/bb__cascades__datetimepicker.html#property-value

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Is there way to use QDateTime and QDate with DateTimePicker in QML/Javascript function?

When you get the result of date picking, the line var dateSelected = datePicker.value in the code, dateSelected is a Javascript date, so you can use any method that Javascript Date class expose.