contract KuaiMintableToken is BonusToken {
    uint256 public standardDailyLimit; // maximum amount of token can mint per day
    uint256 public dailyLimitLeft = standardDecimals.mul(1000000); // daily limit left
    uint256 public lastMintTime = 0;
    event Mint(address indexed operator, uint256 value, uint256 mintTime);
    event SetDailyLimit(address indexed operator, uint256 time);
    function KuaiMintableToken(
                    address operator,
                    uint256 _dailyLimit
                ) BonusToken(operator) {
        totalSupply = 0;
        createTime = now;
        lastMintTime = createTime;
        standardDailyLimit = standardDecimals.mul(_dailyLimit);
    }
    // mint mintAmount token
    function mint(uint256 mintAmount) onlyOperator returns(uint256 _actualRelease) {
        require(!judgeIsReachDailyLimit(mintAmount, timestamp));
        uint256 timestamp = now;
        balances[owner] = balances[owner].add(mintAmount);
        totalSupply = totalSupply.add(mintAmount);
        Mint(msg.sender, mintAmount, timestamp);
        return mintAmount;
    }
    function judgeIsReachDailyLimit(uint256 mintAmount, uint256 timestamp) internal returns(bool _exist) {
        bool reached = false;
        if (dailyLimitLeft > 0) {
            if ((timestamp.parseTimestamp().year == lastMintTime.parseTimestamp().year)
                && (timestamp.parseTimestamp().month == lastMintTime.parseTimestamp().month)
                && (timestamp.parseTimestamp().day == lastMintTime.parseTimestamp().day)) {
                if (dailyLimitLeft < mintAmount) {
                    reached = true;
                } else {
                    dailyLimitLeft = dailyLimitLeft.sub(mintAmount);
                    lastMintTime = timestamp;
                }
            } else {
                dailyLimitLeft = standardDailyLimit;
                lastMintTime = timestamp;
                if (dailyLimitLeft < mintAmount) {
                    reached = true;
                } else {
                    dailyLimitLeft = dailyLimitLeft.sub(mintAmount);
                }
            }
        }
        return reached;
    }
    // set standard daily limit
    function setDailyLimit(uint256 _dailyLimit) onlyOwner returns(bool){
        standardDailyLimit = _dailyLimit;
        SetDailyLimit(msg.sender, now);
        return true;
    }
}
function setDailyLimit(uint256 _dailyLimit) onlyOwner returns(bool){
    standardDailyLimit = _dailyLimit;
    SetDailyLimit(msg.sender, now);
    return true;
}

// set standard daily limit