How do I use the Time class. Do I use it as a subclass or can I create a Time component?
I have tried both ways and I can’t get it to work…can anybody take a few minutes to explain to me how to use the Time class?
Never mind, I think I have figured it out…I will repost if I am still having trouble…
Still haven’t got it completely…what does the getCurrentTime method actually return?
How do I reference a Time object?
The currentTimeMillis is working as it returns an int64 but I have no idea what a returned Time object is…
Ok I have got it to work but I still don’t understand it all…
It’s a very straightforward c++ class, with no fancy stuff at all, so I’m not sure what I could explain about it that you couldn’t also learn from any introductory c++ book!
yes well that is the issue, i am learning juce and c++ at the same time…thanks for your help along the way
Time is just an object which holds a value describing a ‘time’, and provides functionality to manipulate/inspect it in meaningful/relevant ways. Of course, creating one (as the docs describe) doesn’t automatically give it a useful internal value [it starts initialised to the earliest time it can represent; the dawn of the computer age ].
You can create one to describe a specific time (using one of the constructors), or you can use one of the static functions to create one for a given purpose. In case you didn’t know, a ‘static’ class function is a type of function which can be called without an instance. With normal functions, you’d call them from an object instance, like “MyTimeObject.getMinutes()”. With static functions, you use the class name and the ‘scope resolution operator’ (: and call the function directly; e.g. calling Time::getCurrentTime() will return a Time object whose value represents the system time at the moment it was called. So, if you do this:
Time currentTime = Time::getCurrentTime();
… the object ‘currentTime’ will hold the system time at that instant. You can then find out more about that stored time by using the various functions from that instance.