Truncate lastHeartbeat to day millis
This commit is contained in:
parent
7adfd1a4e7
commit
af66a5b265
3 changed files with 28 additions and 5 deletions
|
@ -3,7 +3,11 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { isOlderThan, isMoreRecentThan } from '../../util/timestamp';
|
||||
import {
|
||||
isOlderThan,
|
||||
isMoreRecentThan,
|
||||
toDayMillis,
|
||||
} from '../../util/timestamp';
|
||||
|
||||
const ONE_HOUR = 3600 * 1000;
|
||||
const ONE_DAY = 24 * ONE_HOUR;
|
||||
|
@ -34,4 +38,17 @@ describe('timestamp', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toDayMillis', () => {
|
||||
const now = new Date();
|
||||
const today = new Date(toDayMillis(now.valueOf()));
|
||||
|
||||
assert.strictEqual(today.getUTCMilliseconds(), 0);
|
||||
assert.strictEqual(today.getUTCHours(), 0);
|
||||
assert.strictEqual(today.getUTCMinutes(), 0);
|
||||
assert.strictEqual(today.getUTCSeconds(), 0);
|
||||
assert.strictEqual(today.getUTCDate(), now.getUTCDate());
|
||||
assert.strictEqual(today.getUTCMonth(), now.getUTCMonth());
|
||||
assert.strictEqual(today.getUTCFullYear(), now.getUTCFullYear());
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue