Checking is parsed time has passed since last check
In my system, a trigger time is given, but units after a certain point are ignored when matching. Ex:
Trigger (mm-ss): 10-15
With this trigger, the time will be matched every year, month, day, and hour when the time is at 10 minutes and 15 seconds.
Since the match check occurs at an unknown interval, the system needs to check if the time would have matched since the last check() call. This is done like this:
1. Create new current date
2. Check if the trigger date is after the previous check, and before the current time
3. Update previous check date
All dates are parsed using SimpleDateFormat, which will give default values for undefined times. For example, (mm-ss): "10-15" will result in "Thu Jan 01 00:10:15 PST 197"
The problem occurs when a trigger has a unit of time that is close to 0. Here is what happens when the trigger *should* occur:
Trigger: Thu Jan 01 00:00:00 PST 1970
Previous: Thu Jan 01 00:00:58 PST 1970
Current: Thu Jan 01 00:00:03 PST 1970
As you can see, the previous time wraps around, causing it to come after the trigger, instead of before.
Here is the full code: https://gist.github.com/Sprakle/5561925
I've been stumped for a while, so any input is appreciated.