Created
January 18, 2013 14:40
-
-
Save sassembla/4564980 to your computer and use it in GitHub Desktop.
TimeAssert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait TimeAssert { | |
val SecUnit = 1000 | |
def timeAssert(timestamp: String, message: String, delaySec: Int = 0) = { | |
val timestampDate = new SimpleDateFormat("MM/dd/yy HH:mm:ss").parse(timestamp) | |
val limit = timestampDate.getTime + delaySec * SecUnit | |
val currentDate = new Date | |
val currentDateTime = currentDate.getTime | |
val distance = (limit - currentDateTime) | |
assert(0 < distance, "TimeAssert BOMB:" + message + " /" + distance / SecUnit + " sec over") | |
println("TimeAssert passed:" + message + " /" + distance / SecUnit + " sec left") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
timeAssert("01/18/13 23:55:36", "fix here, me.", 60)
will BOMB 01/18/13 23:56:36