-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from melfore/105-timeline-time-related-types
[Timeline] Time related types
- Loading branch information
Showing
13 changed files
with
147 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export { Resource } from "./resources/utils/resources"; | ||
export { TaskData } from "./tasks/utils/tasks"; | ||
export { KonvaTimelineError } from "./utils/operations"; | ||
export { TimeRange } from "./utils/time-range"; | ||
export { TimeRange } from "./utils/time"; | ||
export { RESOLUTIONS, Resolution } from "./utils/time-resolution"; | ||
|
||
export { default as KonvaTimeline } from "./KonvaTimeline"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DateTime, Interval } from "luxon"; | ||
|
||
export interface TimeRange { | ||
/** | ||
* Start of time range interval | ||
*/ | ||
start: number | string; | ||
/** | ||
* End of time range interval | ||
*/ | ||
end: number | string; | ||
} | ||
|
||
export interface InternalTimeRange { | ||
start: number; | ||
end: number; | ||
} | ||
|
||
/** | ||
* Returns valid date based on input, otherwise now | ||
* @param date the input date (number or string formats) | ||
*/ | ||
export const getValidTime = (date: number | string): number => { | ||
if (typeof date === "number" && !Number.isNaN(date)) { | ||
return date; | ||
} | ||
|
||
if (typeof date === "string") { | ||
const dateTime = DateTime.fromISO(date, { zone: "utc" }); | ||
if (dateTime.toISO() === date) { | ||
return dateTime.toMillis(); | ||
} | ||
} | ||
|
||
return DateTime.now().toMillis(); | ||
}; | ||
|
||
/** | ||
* Converts a TimeRange to a luxon Interval | ||
* @param range TimeRange to convert | ||
*/ | ||
export const getIntervalFromInternalTimeRange = ({ start, end }: InternalTimeRange): Interval => { | ||
return Interval.fromDateTimes(DateTime.fromMillis(start), DateTime.fromMillis(end)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters