contract TealToken is ERC20 {
    string private _name;
    string private _symbol;
    uint8 private _decimals;
    TealCoin public _tlc;
    bool public _allowMinting;
    address public owner;
    mapping (address => uint256) private _lastTimeMinted;

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner is allowed to do this");
        _;
    }

    function setAllowMinting(bool _value) public onlyOwner {
        _allowMinting = _value;
    }
    
    /**
     * @dev Constructor.
     * @param tlc TlcCoin contract to connect
     */
    constructor(TealCoin tlc) public payable {
      _name = 'TealToken';
      _symbol = 'TLT';
      _decimals = 0;
      _tlc = tlc;
      
      owner = msg.sender;
      
      _allowMinting = true;

      // set tokenOwnerAddress as owner of initial supply, more tokens can be minted later
      _mint(msg.sender, 9000000);
    }

    /**
     * @dev See `ERC20._mint`.
     *
     * Requirements:
     *
     * - Can be called by the same wallet once per month.
     */
    function mint(address account, uint256 amount) public returns (bool) {
        require(_allowMinting, "Minting is not allowed");
        
        uint256 lastTime = _lastTimeMinted[msg.sender];
        
        require(lastTime == 0 || now > lastTime + 1 days, "You need to wait at least one day since the last minting");
        
        _lastTimeMinted[msg.sender] = now;

        _mint(account, amount);
        
        uint256 tlcAmount = amount.mul(4167);
        
        if (lastTime > 0) {
            uint256 diffInDays = (now - lastTime).div(86400); //60 * 60 * 24
            if (diffInDays > 730) {
                diffInDays = 730;
            }
            tlcAmount = tlcAmount.mul(diffInDays);
        }
        
        _tlc.mint(account, tlcAmount);

        return true;
    }

    // optional functions from ERC20 stardard

    /**
     * @return the name of the token.
     */
    function name() public view returns (string memory) {
      return _name;
    }

    /**
     * @return the symbol of the token.
     */
    function symbol() public view returns (string memory) {
      return _symbol;
    }

    /**
     * @return the number of decimals of the token.
     */
    function decimals() public view returns (uint8) {
      return _decimals;
    }
}
function symbol() public view returns (string memory) {
      return _symbol;
    }
/**
 * @return the symbol of the token.
 */