####Preface
A couple days ago I wanted to do a simple time comparison for a process, so I wrote a Stopwatch class. It was a stupid Stopwatch class so I rewrote it three times and stayed up until midnight. Now its a nice Stopwatch class, and I figured I’d share it.
####What is it?
This resource is a single class that you can use in your project if you want. The class has the ability to count time elapsed, be dynamically paused and stopped, and potentially be used for cooldowns. Moreover, it’s not as performance heavy as a repeating task (which is probably one of the worst ways to go about cooldowns, and yes, I’ve done it that way before). It can also give you human-readable representations of the time elapsed, in the form “[hours] Hours, [minutes] Minutes, [seconds] Seconds, and [millis] Milliseconds,” times that are 0 are not included, and milliseconds can be optionally rounded.
###Cooldowns
You can use the class for cooldowns by using the until
or humanReadableUntil
methods. These methods return the amount of time until the time elapsed reaches the passed in time.
###Benefits
- Thread-safe
- Reasonably efficient
- Makes pretty human readable strings
- Fully documented
###Drawbacks
- Doesn’t display days, or any greater period of time
- Written by a mad scientist
####Where is it?
Righter here: