I had a similar issue, solved it with a function that refreshes time limit to zero if conditions are met.
First you need to create your own constant variable DAY,
uint constant DAY = 60 * 60 * 24; // Number of seconds in a day
/**
* Refreshes the transfer limit of the given address if it has been more than 24h since it last sent funds.
*/
function refreshTimeLimit(address addr, address tokenAddress) public {
if (block.timestamp - _stakingUserBalance[addr].Token[tokenAddress].transactionTime > DAY) {
_stakingUserBalance[addr].Token[tokenAddress].lastTransactionDate = block.timestamp;
_stakingUserBalance[addr].Token[tokenAddress].stakedAmount = 0;
}
}
/**
* Returns the time/date of the last transaction from this address.
*/
function transactionTime(address addr, address tokenAddress) public view returns (uint){
return _stakingUserBalance[addr].Token[tokenAddress].lastTransactionDate;
}
/**
* Returns the amount that had been stacked from the address in the last 24h.
*/
function stakedSum(address addr, address tokenAddress) public view returns (uint){
return _stakingUserBalance[addr].Token[tokenAddress].stakedAmount;
}