Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125587

Cannot create DateTime from StdTimePoint

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4, 6.7.0
    • Core: Date/Time
    • None
    • Windows
    • 2
    • e95812df8 (dev), 6197078fb (6.7), 48ab909c5 (dev)
    • Foundation Sprint 108, Foundation Sprint 109, Foundation Sprint 110, Foundation Sprint 111, Foundation Sprint 112, Foundation Sprint 113, Foundation Sprint 114, Foundation Sprint 115, Foundation Sprint 116, Foundation Sprint 117, Foundation Sprint 118, Foundation Sprint 119, Foundation Sprint 120, Foundation Sprint 121, Foundation Sprint 122

    Description

      I cannot create a QDateTime object from a std TimePoint:

       

      QDateTime::fromStdTimePoint(std::chrono::system_clock::now())

      This snippet does not compile on Windows, because of the constraints:

       

      requires(const std::chrono::time_point<Clock, Duration> &t) {
          // the clock can be converted to system_clock
          std::chrono::clock_cast<std::chrono::system_clock>(t);
          // the duration can be converted to milliseconds
          requires std::is_convertible_v<Duration, std::chrono::milliseconds>;
      } 

       

       

      The Duration type of the system clock's time point is implementation defined. In may case (VS2022) it is probably larger than std::chrono::milliseconds, so it cannot be implicitly converted.

      Since the implementation uses a std::chrono::time_point_cast anyways, maybe the constraint can be dropped (or maybe use the time_point_cast inside the requires clause).

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peppe Giuseppe D'Angelo
            jdoubleu jdoubleu
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes