[REQ] [Qt5] [C++] Allow for dateTime format to be ISODateWithMs (not just ISODate)
Created by: xconverge
Is your feature request related to a problem? Please describe.
I would like to use ISODateWithMs and right now the only way to do that is to call:
SerializerSettings
bool setDateTimeFormat(const QString& dateTimeFormat);
and hope that you can supply a QString that meets your needs.
Here is the current code for serializing datetimes
QString toStringValue(const QDateTime &value) {
// ISO 8601
return SerializerSettings::getInstance()->getDateTimeFormat().isEmpty()? value.toString(Qt::ISODate):value.toString(SerializerSettings::getInstance()->getDateTimeFormat());
}
Describe the solution you'd like
I would like to also have the option of setting Qt::ISODateWithMs to the serializer. trying to do it manually with the string is difficult due to timezones.
I can do a few things:
- add a boolean to SerializerSettings called useMsInDateTime, which then switches between Qt::ISODate and Qt::ISODateWithMs
- add a setter for setDateTimeFormat overloaded to accept a Qt::DateFormat and then adjust the logic in toStringValue to also look for if this was set and use it if so.
Describe alternatives you've considered
"yyyy-MM-ddTHH:mm:ss.zzzZ" "yyyy-MM-ddTHH:mm:ss.zzz[Z|[+|-]HH:mm]" etc all have issues with timezones when passed in as just a string format. So the ability to pass the enum as well would fix this