I've noted the "ap/a/AP/a" is missing while converting a date to string. For "h:m:s ap", i.e., I get "11:5:42 ". The same happens for each of the "ap/a/AP/a" forms.
What I'm missing?
void DecoderBr1::recordOnFile(QDateTime dateTime, QByteArray ba)
{
QString filename(dateTime.toString("yyyy MMMM [email protected] zzz ap"));
filename.append(".log");
Recorder recorder;
recorder.recordFile(filename, ba);
}
It depends on your locale. Not every locale support AM/PM format. For example, my default locale is "it_IT" and does not print "AM/PM". Setting another locale (e.g. "en_EN") instead works as expected.
QDateTime t = QDateTime::fromString("2015-07-16T19:20:30+01:00", Qt::ISODate);
QString st = t.toString("yyyy MMMM [email protected] zzz ap");
QString locale_st_HH = QLocale("en_EN").toString(t, "yyyy MMMM [email protected] zzz ap");
QString locale_st_hh = QLocale("en_EN").toString(t, "yyyy MMMM [email protected] zzz ap");
qDebug() << st;
// With italian locale does not print AM/PM
// "2015 luglio [email protected] 000 "
qDebug() << locale_st_HH;
// With en_EN locale it works
//"2015 July [email protected] 000 pm"
qDebug() << locale_st_hh;
// With en_EN locale it works
// With hh it prints 07 pm instead of 19 pm // Credits to @t3ft3l--i
//"2015 July [email protected] 000 pm"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With