[odb-users] Problem with QDate and Sqlite when it's mapped with TEXT type

Boris Kolpackov boris at codesynthesis.com
Thu Sep 10 10:31:34 EDT 2015


Hi Ali,

> The problem is related to my operating system locale, because Qt
> uses operating system locale. My OS locale is Persian.
> 
> odb\qt\date-time\sqlite\qdate-traits.hxx, Line 64:
> 
> std::string s (v.toString ("yyyy-MM-dd").toLatin1 ().constData ());
> 
> must be changed to:
> 
> std::string s(QLocale(QLocale::English).toString(v, "yyyy-MM-dd").toLatin1().constData());

Thanks for tracking it down. The problem with the proposed fix is
that locales are quite heavy-weight. I am not 100% sure about Qt
but standard ones are. So I am not sure it would make sense to
impose this overhead on cases where it is not necessary, which
is probably 99% of all of them.

We have the same issue with using stringstream to parse integers,
etc. When we switch to C++11, the plan is to use to_string()/sto*()
instead which always use "C" locale. I wonder if there is a similar,
locale-independent Date/Time parsing support in Qt?

Boris



More information about the odb-users mailing list