Error on getTime

I have an application that consists of two main components a Web browser and a mobile app.

Those two interact with the DAML ledger via the exact same API.

The problem I have now is because when one of the choices is performed by the mobile app, it throws an error FAILED_PRECONDITION: DAML_INTERPRETATION_ERROR, the error message thrown matches the following part on the DAML model:

now ← getTime
assertMsg “Outside time window” $contract.startTime <= now <= contract.endTime

I tried to set a large time window of 1900 - 2100 and the error persisted.
Additionally, previous steps have the same logic but are working properly on both the browser and the mobile app.

Does anyone know what could be the cause of this problem?

Can you include contract.startTime, contract.endTime and now and share the values once you get the error?

One option may be a timezone thing: Daml ledger time is in UTC. If you set some time on the client side, maybe your mobile app uses local time or something like that.

thanks for your reply. How do you recommend doing this? I tried assertMsg “Outside time window” <> show now $contract.startTime <= now <= contract.endTime
But I could not even build the model with this code, I searched for other possibilities but nothing seemed to work on how to cope with this problem :frowning: .

assertMsg takes two arguments. The first is the text used if the assertion fails, the second is the boolean you want to test. So in your example, something like this should work:

  ("Current time " <> show now <> 
   " is outside time window " <> show (contract.starteTime, contract.endTime)) 
  (contract.startTime <= now && now <= contract.endTime)
1 Like

This meant to output the error data, but turned out to be the solution for fixing the code :wink: