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: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile

ListItem date access

[ Edited ]

hi, 

i'm in front of my next problem, want to edit the timeformat as is should say how many time since the last update past,

i mean instead of 2013-10-08T17:27:59.745Z  1 if the lastUpdate was yesterday, 2 for the day before yesterday and so on.

that means that i have to compare it to the current date but i dont know how i can get access to the lastUpdate Variant in my Map.

 

QMap(("weather", QVariant(QVariantList, (QVariant(QVariantMap, QMap(("citydocid", QVariant(QString, "") ) ( "id" ,  QVariant(qlonglong, 94) ) ( "city" ,  QVariant(QString, "test") ) ( "lastUpdate" ,  QVariant(QString, "2013-1008T17:23:39.154Z") ) ) ) ) )

 

Hope you can help me again.

thanks in advance

 

 

Subject Title edited to reflect new topic.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListItem date access

[ Edited ]

One problem per thread please, please post your new problem as a new thread.

 

[Edit] If you click on the link 'Report inappropriate content' next to the message above you can then ask a moderator to split the thread for you. This is a better way to do it to avoid replication.

 

[Edit 2] Please don't open a new thread as I've asked the moderator to split the thread.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListItem date access

[ Edited ]

What does ListItemData.lastUpdate return?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
Posts: 17
Registered: ‎07-31-2013
My Device: Q10
My Carrier: T-Mobile

Re: ListItem date access

[ Edited ]

it returns a string for example: 

"2013-1008T17:23:39.154Z"
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListItem date access

[ Edited ]

Yes so as per my earlier suggestion I recommend converting it to a QDateTime and then you can use the functions within that to help you...

 

http://harmattan-dev.nokia.com/docs/library/html/qt4/qdatetime.html#daysTo


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListItem date access

[ Edited ]

Before @Zmey chips in with it you can also use QML's date object... Smiley Wink

 

http://qt-project.org/doc/qt-4.8/qml-date.html

 

Personally I prefer to work with QDateTime it's more extensive.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: ListItem date access

Hehe. Smiley Happy

 

There are also lots of ready-made JavaScript snippets, for example prettyDate function from this link:

http://ejohn.org/blog/javascript-pretty-date/

http://ejohn.org/files/pretty.js

 


Andrey Fidrya, @zmeyc on twitter