fix(core): update
This commit is contained in:
parent
2b21ee9a24
commit
5a9584917c
@ -1,27 +0,0 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smarttime from '../ts/index';
|
||||
|
||||
let testCronManager: smarttime.CronManager;
|
||||
|
||||
tap.test('should create a valid instance of cronmanager', async () => {
|
||||
testCronManager = new smarttime.CronManager();
|
||||
expect(testCronManager).to.be.instanceOf(smarttime.CronManager);
|
||||
});
|
||||
|
||||
tap.test('should create a valid cronJon', async (tools) => {
|
||||
const done = tools.defer();
|
||||
let counter = 0;
|
||||
testCronManager.addCronjob('*/2 * * * * *', async () => {
|
||||
if (counter === 10) {
|
||||
done.resolve();
|
||||
}
|
||||
counter++;
|
||||
console.log(`hey ${counter}`);
|
||||
});
|
||||
testCronManager.start();
|
||||
await done.promise;
|
||||
testCronManager.stop();
|
||||
});
|
||||
|
||||
tap.start();
|
@ -1,4 +1,5 @@
|
||||
import * as plugins from './smarttime.plugins';
|
||||
import * as units from './smarttime.units';
|
||||
|
||||
export type TAvailableZone = 'Europe/Berlin';
|
||||
|
||||
@ -126,7 +127,20 @@ export class ExtendedDate extends Date {
|
||||
return plugins.dayjs(this.getTime()).format(formatArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* boolean checks
|
||||
*/
|
||||
public isToday () {
|
||||
return plugins.dayjs(this.getTime()).isToday();
|
||||
}
|
||||
|
||||
public lessTimePassedToNow(unitArgs: units.IUnitCombinationArg): boolean {
|
||||
const maxPassedUnixTime = units.getMilliSecondsFromUnits(unitArgs);
|
||||
const actualPassedUnixTime = Date.now() - this.getTime();
|
||||
return actualPassedUnixTime < maxPassedUnixTime;
|
||||
}
|
||||
|
||||
public moreTimePassedToNow(unitArgs: units.IUnitCombinationArg) {
|
||||
return !this.lessTimePassedToNow(unitArgs);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user