Closed bhdouglass closed 5 years ago
Hmm you got a quick fix for me how to convert date and time in Qt? I am currently browsing all various kinds of documents, but nowhere I find how to determine if the system local uses 12 or 24 hrs.
Is it possible to do something like this? http://doc.qt.io/qt-5/qml-qtqml-date.html#toLocaleDateString-method
Oh, someone filed an analogue issue for the calendar... ;-) That's how i'll do it there in one place: Qt.formatTime( new Date(0,0,0,index), Qt.SystemLocaleShortDate)
Eh where goes the date I want to display in this string?
Working on this now... @bhdouglass can you help with the following formats and their respective System locale identifier or idk:
QString Cutegram::getTimeString(const QDateTime &dt)
{
if( QDate::currentDate() == dt.date() ) // TODAY
// TRANSLATORS: Format string: time.
return dt.toString(tr("HH:mm"));
else
if( dt.date().daysTo(QDate::currentDate()) < 7 )
// TRANSLATORS: Format string: day and time (ex. Tue 21:30)
return dt.toString(tr("ddd HH:mm"));
else
if( dt.date().year() == QDate::currentDate().year() )
// TRANSLATORS: Format string: day and month (ex. 28 Feb)
return dt.toString(tr("dd MMM"));
else
// TRANSLATORS: Format string: full date
return dt.toString(tr("dd MMM yy"));
}
...and forget the translation, probably can be removed
For en_US (and anywhere else that uses am/pm) this is what I would suggest:
HH:mm
-> hh:mm ap
ddd HH:mm
-> ddd hh:mm ap
I have my locale set to English/US in the system settings. I would expect that the message times be shown in am/pm, but instead it shows 24 hour time (14:30 vs 2:30pm). This is for both the conversation view, the list of conversations, and the group member view (possibly the "last online time" thing as well for the personal conversations).