Skip to content

[REQ] [Qt5][client][server] Use a particular DateTime format during saving model as a JSON string #5708

@goodicus

Description

@goodicus

Is your feature request related to a problem? Please describe.

I'm using c++ Qt5 client and server in a network mediator application.
The app receives JSONs, collects them and resends to the Java server using a schedule.
The Java server is generated with OpenAPI also.
The problem is there is a DateTime format mismatch between Qt5 [client/server] and JAVA.

  • Java server excepts Jsons with such DateTime format:
    with
    "2017-07-08T22:35:29.771Z" - suffix Z, means UTC time
    "2017-07-08T22:35:29+02:30" - time zone
    "2017-07-08T22:35:29.771+02:30" - with a suffix and a timezone
  • Qt5 generates by default in such way:
    " 2017-07-08T22:35:29" - withnout Z and a timezone.

Describe the solution you'd like

Currently, QDateTime transforms into a string using a Qt::ISODate format.
QString toStringValue( const QDateTime& value ) {
// ISO 8601
return value.toString( Qt::ISODate );
}

It would be useful for me to set a particular DateTime format option during code generation.
Example for cpp-qt5-client:
useQDateTimeFormat="yyyy-MM-ddTHH:mm:ss.zzzZ";
Smth like this:
QString const DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.zzzZ";
QString toStringValue( const QDateTime& value ) {
return value.toString( QtDateTimeFormat );
}

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions