Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Moved] QdateTime

[Moved] QdateTime

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 4.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darmonjj
    wrote on last edited by
    #1

    I am trying to convert a C# program that use Datetime class.
    The precision on this class in C# is in tick - equivalent to 0.1 micro second .
    Has anybody done some work on Qdatetime to inherit this class and modify the api to be able to handle this precision?
    Is this the best way to start?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kalle
      wrote on last edited by
      #2

      QDateTime wasn't really written to be extensible, I am afraid, so subclassing QDateTime doesn't sound like a promising approach. You may have to write your own TickDateTime class. Please also notice that not all platforms support such granularity (one reason that QDateTime is based on milliseconds is that that is a granularity that all platforms supported by Qt these days support themselves).

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        [quote author="kalle" date="1286803210"]Please also notice that not all platforms support such granularity (one reason that QDateTime is based on milliseconds is that that is a granularity that all platforms supported by Qt these days support themselves).[/quote]

        I find this limitation a bit surprising. Java introduced the nanoTime() call in JDK 1.5 and claims to try to get the system time in nano seconds (though not fully accurate), there must be some way to do this in Qt. IMHO millis is really quite limited !!!

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          ygor
          wrote on last edited by
          #4

          0.1 microsecond = 1 nanosecond

          clock_gettime gives seconds and nanoseconds, so there is your answer.

          Do you really need that level of accuracy ?

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            In microsecond yes, have run into "0" ms time taken for many methods while measuring performance. nanosecond .. not yet :)

            also isn't 0.001 micro = 1 nano ?

            1 Reply Last reply
            0
            • I Offline
              I Offline
              ixSci
              wrote on last edited by
              #6

              In microsecond yes, have run into “0” ms time taken for many methods while measuring performance.
              It means you have no to do with these methods optimization, do you?. Besides you should use appropriate software for profiling instead of using custom non-precise methods.
              0.1 microsecond = 1 nanosecond
              1 microsecond = 10^-6
              1 nanosecond = 10^-9
              0.1 microsecond != 1 nanosecond
              Is this the best way to start?
              I think it is better to use platform-dependent methods when you really need such a precision without any Qt wrapping.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                ygor
                wrote on last edited by
                #7

                [quote author="chetankjain" date="1287026068"]also isn't 0.001 micro = 1 nano ?[/quote]

                Silly me, yes, they are an order of magnitude different, but the question stands: Do you REALLY need that much accuracy ?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved