Skip to content

Commit

Permalink
remove cale correction
Browse files Browse the repository at this point in the history
  • Loading branch information
downmix committed Jan 2, 2024
1 parent 1a1f422 commit 1b44cc3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
14 changes: 0 additions & 14 deletions src/time-range/time-range.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,6 @@ describe('TimeRange Util', () => {
});
expect(timeRange8.totalPlayTime()).toEqual(62);
});

it('increased correction totalPlayTime', async () => {
const timeRange1 = new TimeRange();
expect(timeRange1.increaseCorrection(100)).toEqual(100);

const timeRange2 = new TimeRange(); // 0.01%
expect(timeRange2.increaseCorrection(10000)).toEqual(10001);

const timeRange3 = new TimeRange([], 0, 0.001); // 0.1%
expect(timeRange3.increaseCorrection(20000)).toEqual(20020);

const timeRange4 = new TimeRange([], 0, 0.01); // 1%
expect(timeRange4.increaseCorrection(30000)).toEqual(30300);
});
});
});
});
8 changes: 1 addition & 7 deletions src/time-range/time-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import { TimeSection } from './time-range.interface';
/**
* @params loadSection: TimeSection 배열
* @params decimalPlaces: TimeSection 계산시 소수점 자리수를 설정하여 반올림 처리 (default 0)
* @params correction: 모든 클립 playtime의 오차 보정 수치 (default 0.01%)
*/
export class TimeRange {
private section!: Array<TimeSection>;
decimalPlaces: number;
correction: number;
constructor(loadSection: Array<TimeSection> = [], decimalPlaces = 0, correction = 0.0001) {
constructor(loadSection: Array<TimeSection> = [], decimalPlaces = 0) {
this.section = loadSection;
this.decimalPlaces = decimalPlaces;
this.correction = correction;
}
add(piece: TimeSection) {
this.section.push(piece);
Expand Down Expand Up @@ -63,7 +60,4 @@ export class TimeRange {
}, 0);
return NumberUtil.decimalRoundDown(result, this.decimalPlaces);
}
increaseCorrection(allPlayTime: number) {
return allPlayTime + Math.round(allPlayTime * this.correction);
}
}

0 comments on commit 1b44cc3

Please sign in to comment.