daml icon indicating copy to clipboard operation
daml copied to clipboard

assertAfter and assertBefore

Open PIOTR-OSTROWSKI-GFT opened this issue 5 years ago • 0 comments

daml/compiler/damlc/daml-stdlib-src/DA/Assert.daml daml/compiler/damlc/daml-stdlib-src/DA/Internal/Assert.daml

assertAfter/asserAfterMsg and assertBefore/assertBeforeMsg functions should work in the opposite way.

e.g. This is the function assertAfterMsg, it should fail if the date you pass IS NOT in the future - but it fails when the date IS in the future.

-- | Check whether the given time is in the future. If it's not,
-- abort with a message.
assertAfterMsg : (CanAbort m, HasTime m) => Text -> Time -> m ()
assertAfterMsg msg time = do
  now <- getTime
  if time > now
    then abort msg
    else return ()

PIOTR-OSTROWSKI-GFT avatar Feb 27 '20 13:02 PIOTR-OSTROWSKI-GFT