Skip to content

Commit

Permalink
fix(core): add currentTime param to viewportStartDate and `viewportEn…
Browse files Browse the repository at this point in the history
…dDate`
  • Loading branch information
square-li committed Oct 6, 2022
1 parent fb8e333 commit eb02085
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/common/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { MinimalViewPortConfig } from '@synchro-charts/core';
import { isMinimalStaticViewport } from './predicates';
import { parseDuration } from './time';

export const viewportStartDate = (viewportConfig: MinimalViewPortConfig): Date =>
export const viewportStartDate = (viewportConfig: MinimalViewPortConfig, currentDate?: Date): Date =>
isMinimalStaticViewport(viewportConfig)
? new Date(viewportConfig.start)
: new Date(Date.now() - parseDuration(viewportConfig.duration));
: new Date((currentDate?.getTime() || Date.now()) - parseDuration(viewportConfig.duration));

export const viewportEndDate = (viewportConfig: MinimalViewPortConfig): Date => {
return isMinimalStaticViewport(viewportConfig) ? new Date(viewportConfig.end) : new Date(Date.now());
export const viewportEndDate = (viewportConfig: MinimalViewPortConfig, currentDate?: Date): Date => {
return isMinimalStaticViewport(viewportConfig) ? new Date(viewportConfig.end) : currentDate || new Date(Date.now());
};

0 comments on commit eb02085

Please sign in to comment.