6

Currently I'm trying to find a solution for this problem TypeError: Member "toTimestamp" is not available in contract DateTime outside of storage , and I decided to take another approach. I've inherited the DateTime contract and rewritten the method to be as follows:

function _incrementMonths(uint16 _months, uint _timestamp) internal returns (uint){
    uint16 year = getYear(_timestamp);
    uint16 month = getMonth(_timestamp);

    uint16 newMonth = month + _months;
    while(newMonth > 12){
        newMonth -= 12;
        year++;
    }

    // get new timestamp
    uint time = toTimestamp(
        year,
        newMonth,
        getDay(_timestamp),
        getHour(_timestamp),
        getMinute(_timestamp),
        getSecond(_timestamp)
    );
}

However now the compiler gives me this new error:

browser/Payroll.sol:326:21: TypeError: No matching declaration found after argument-dependent lookup.
        uint time = toTimestamp(
                    ^---------^

Again, the contract I'm referencing is found here: https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol . The method I'm calling is found here https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol#L165

I've been trying to debug this, but I don't see what is causing this error. What could be the cause?


Edit:

Please see the code in the IDE I've been working with https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.17+commit.bdeb9e52.js&gist=03e5543f137d3ec464462cc190104de3

2 Answers 2

5

Your newMonth variable is a uint16. The toTimestamp function expects the month parameter to be a uint8.

uint time = toTimestamp(
    year,
    uint8(newMonth),   // <--- if you cast to uint8 the error goes away
    getDay(_timestamp),
    getHour(_timestamp),
    getMinute(_timestamp),
    getSecond(_timestamp)
);
0
0

For this error: TypeError: No matching declaration found after argument-dependent lookup:

It might happen because toTimestamp(... should has a public visibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.