Script Field - version change

guys, I'm changing from version 6.5 to version 7.9 and I need to redo the fields scripts.
They're not working the same way, I've done some research but I couldn't.
this example is what i did in 6.5 and it's working, i would like your invaluable help to pass it to the default which would be 7.9.
thank you very much for any help.

def temdata = doc['fechamento'].empty;
def calculo = (doc['fechamento'].date.millis - doc['abertura'].date.millis) ;
if (temdata==false) { return calculo; } else { return 0; }