forked from ivan-lednev/obsidian-day-planner
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda361f
commit 7d07d1c
Showing
7 changed files
with
99 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getDiffInMinutes } from "../util/moment"; | ||
import { DEFAULT_DURATION_MINUTES } from "../constants"; | ||
import type { createPlanItem } from "./parser"; | ||
|
||
export function calculateDefaultDuration( | ||
item: ReturnType<typeof createPlanItem>, | ||
next?: ReturnType<typeof createPlanItem>, | ||
) { | ||
if (item.endTime) { | ||
return getDiffInMinutes(item.startTime, item.endTime); | ||
} | ||
|
||
if (next) { | ||
const minutesUntilNext = getDiffInMinutes(next.startTime, item.startTime); | ||
|
||
if (minutesUntilNext < DEFAULT_DURATION_MINUTES) { | ||
return minutesUntilNext; | ||
} | ||
} | ||
|
||
return DEFAULT_DURATION_MINUTES; | ||
} |
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
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