Hi guys,
I'm developing a library that extends the Date Object:
// FILE Prop.gs
/**
* constructor
*/
class EadDate extends Date {
constructor() {
super();
this.msperday = 1000 * 60 * 60 * 24;
}
};
/**
* date copy
*/
EadDate.prototype.copy = function () {
return new Date( this.getTime() );
}
/**
* getDaysBetween
*/
EadDate.prototype.getDaysBetween = function( EadDateEnd ) {
cloneDate = EadDateEnd.copy();
cloneDate.setHours( this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds() );
let diff = cloneDate.getTime() - this.getTime();
return ( diff ) / this.msperday;
}
When I do test any function 'locally', It works fine!
let birthday = new EadDate( '06/04/2021' );
let daysLeft = eadate.getDaysBetween( birthday );
console.log( `daysLeft= ${daysLeft}` );
Console:
Info
daysLeft= 32
Then, I do link the library's actual version to another gs file and I do test again:
// FILE
test.gs with the library linked
/**
* TEST_Ead
*/
function TEST_Ead() {
let eadate = new Prop.EadDate( '05/03/2021' ); << ERROR IN THIS LINE
let birthday = new Prop.EadDate( '06/04/2021' );
console.log( `days= ${eadate.getDaysBetween( birthday )}` );
};
I get the following error:
Error
TypeError: Prop.EadDate is not a constructor
I'm using the new editor. Any advice or comment about what's going on?
Thanks in advance for any help.
Jorge.
