Skip to content

Commit 62f6a05

Browse files
Kagamihara Nadeshikoaxmmisaka
authored andcommitted
Accomodate new linting rule; remove plural aliases of TimeValue
1 parent 2f70215 commit 62f6a05

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

__tests__/time.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("time helper functions", function () {
1515
// Non-zero time intervals.
1616
const fiveSeconds: TimeValue = TimeValue.withUnits(5, TimeUnit.sec);
1717
const fiveSFiveUS: TimeValue = TimeValue.withUnits(5000005, TimeUnit.usec);
18-
const fortyTwoDays: TimeValue = TimeValue.withUnits(42, TimeUnit.days);
18+
const fortyTwoDays: TimeValue = TimeValue.withUnits(42, TimeUnit.day);
1919
const threeHundredUS: TimeValue = TimeValue.withUnits(300, TimeUnit.usec);
2020
const sevenPointFiveBillNS: TimeValue = TimeValue.withUnits(
2121
7500000000,
@@ -178,7 +178,7 @@ describe("add time value", function () {
178178
// This test should generate an error because we're trying to convert
179179
// a number which can't be represented as a numeric time interval.
180180
expect(() => {
181-
TimeValue.withUnits(Number.MAX_SAFE_INTEGER, TimeUnit.weeks);
181+
TimeValue.withUnits(Number.MAX_SAFE_INTEGER, TimeUnit.week);
182182
}).toThrowError();
183183
});
184184

src/core/time.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ export enum TimeUnit {
1313
usec = 1000,
1414
msec = 1000000,
1515
sec = 1000000000,
16-
secs = 1000000000,
1716
minute = 60000000000,
18-
minutes = 60000000000,
1917
hour = 3600000000000,
20-
hours = 3600000000000,
2118
day = 86400000000000,
22-
days = 86400000000000,
23-
week = 604800000000000,
24-
weeks = 604800000000000
19+
week = 604800000000000
2520
}
2621

2722
/**
@@ -306,7 +301,7 @@ export class TimeValue {
306301
} else if (this.seconds === Number.MAX_SAFE_INTEGER) {
307302
buff.writeBigUInt64LE(BigInt(0x7fffffffffffffffn), 0);
308303
} else {
309-
const billion = BigInt(TimeUnit.secs);
304+
const billion = BigInt(TimeUnit.sec);
310305
const bigTime = BigInt(this.nanoseconds) + BigInt(this.seconds) * billion;
311306

312307
// Ensure the TimeValue fits into a 64 unsigned integer.
@@ -327,7 +322,7 @@ export class TimeValue {
327322
* @param buffer A 64 bit unsigned integer. Little endian.
328323
*/
329324
public static fromBinary(buffer: Buffer): TimeValue {
330-
const billion = BigInt(TimeUnit.secs);
325+
const billion = BigInt(TimeUnit.sec);
331326

332327
// To avoid overflow and floating point errors, work with BigInts.
333328
const bigTime = buffer.readBigUInt64LE(0);
@@ -362,7 +357,7 @@ export class TimeValue {
362357
throw new Error("Negative time values are illegal.");
363358
}
364359

365-
const billion = BigInt(TimeUnit.secs);
360+
const billion = BigInt(TimeUnit.sec);
366361

367362
// To avoid overflow and floating point errors, work with BigInts.
368363
const bigT = BigInt(value) * BigInt(unit);

0 commit comments

Comments
 (0)