ubports / telegram-app

Unofficial Telegram App for Ubuntu Desktop & Mobile
GNU General Public License v3.0
55 stars 23 forks source link

Times not respecting my locale #170

Closed bhdouglass closed 5 years ago

bhdouglass commented 6 years ago

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).

Flohack74 commented 6 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.

bhdouglass commented 6 years ago

Is it possible to do something like this? http://doc.qt.io/qt-5/qml-qtqml-date.html#toLocaleDateString-method

hummlbach commented 6 years ago

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)

Flohack74 commented 6 years ago

Eh where goes the date I want to display in this string?

Flohack74 commented 5 years ago

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

bhdouglass commented 5 years ago

For en_US (and anywhere else that uses am/pm) this is what I would suggest: