Skip to content
This repository has been archived by the owner on Aug 8, 2022. It is now read-only.

Commit

Permalink
ISODurationWeekdays
Browse files Browse the repository at this point in the history
  • Loading branch information
frodehansen2 committed Mar 21, 2022
1 parent bb21dc1 commit 8e3cd30
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sif-common-utils/durationWeekdaysUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { NumberDuration, DurationWeekdays, summarizeDurations, Duration } from '.';
import { durationToISODuration } from './durationUtils';
import { ISODurationWeekdays } from './types';

export const summarizeDurationInDurationWeekdays = (weekdays: DurationWeekdays): NumberDuration => {
return summarizeDurations([
Expand All @@ -25,3 +27,19 @@ export const getDurationForISOWeekday = (durationWeekdays: DurationWeekdays, wee
}
return undefined;
};

export const durationWeekdaysToISODurationWeekdays = ({
monday,
tuesday,
wednesday,
thursday,
friday,
}: DurationWeekdays): ISODurationWeekdays => {
return {
monday: monday ? durationToISODuration(monday) : undefined,
tuesday: tuesday ? durationToISODuration(tuesday) : undefined,
wednesday: wednesday ? durationToISODuration(wednesday) : undefined,
thursday: thursday ? durationToISODuration(thursday) : undefined,
friday: friday ? durationToISODuration(friday) : undefined,
};
};
8 changes: 8 additions & 0 deletions src/sif-common-utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export type DurationWeekdays = {
[Weekday.friday]?: Duration;
};

export interface ISODurationWeekdays {
[Weekday.monday]?: ISODuration;
[Weekday.tuesday]?: ISODuration;
[Weekday.wednesday]?: ISODuration;
[Weekday.thursday]?: ISODuration;
[Weekday.friday]?: ISODuration;
}

export interface Duration {
hours: string;
minutes: string;
Expand Down

0 comments on commit 8e3cd30

Please sign in to comment.