Skip to content

Commit

Permalink
fix bug causing weekdays to be displayed as daily
Browse files Browse the repository at this point in the history
  • Loading branch information
niels committed Sep 29, 2020
1 parent 5535900 commit d518553
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/date-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ export function daysToArray(dayCfg: IDays): number[] {
export function ArraytoDays(input: number[]): IDays {
let alldays = [1, 2, 3, 4, 5, 6, 7], weekdays = [1, 2, 3, 4, 5];
let dayArray = [...input].sort().filter(e => e != 0);

if (dayArray.every((e, i) => e == alldays[i])) return { type: EDayType.Daily, custom_days: [] };
else if (dayArray.every((e, i) => e == weekdays[i])) return { type: EDayType.Weekdays, custom_days: [] };
if (dayArray.length == alldays.length && dayArray.every((e, i) => e == alldays[i])) return { type: EDayType.Daily, custom_days: [] };
else if (dayArray.length == weekdays.length && dayArray.every((e, i) => e == weekdays[i])) return { type: EDayType.Weekdays, custom_days: [] };
else return { type: EDayType.Custom, custom_days: dayArray };
}

Expand Down

0 comments on commit d518553

Please sign in to comment.