Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify pure weekday/weekend day-of-week combos #95

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function DaysContainer(){
return (
<FactorContainer>
<BigButton onClick={addDays}>
Create a new day of week selection
Create a new day-of-week selection
</BigButton>
<FactorList factors={data.days}/>
</FactorContainer>
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/days.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const daylist = [
{ iso: 7, js: 0, label: 'Sunday' } // note the different numeric representation
]

const weekday = new Set([1,2,3,4,5])
const weekend = new Set([6,7])

export class Days extends Factor {
// initialize with all days included
#days = new Set(daylist.map(d=>d.iso))
Expand All @@ -37,7 +40,17 @@ export class Days extends Factor {
}
get name(){
if(this.#days.size == 7){
return 'all days of the week'
return 'all days'
} else if(
this.#days.size == weekday.size
&& [...weekday].every(v => this.#days.has(v))
){
return 'weekdays'
} else if(
this.#days.size == weekend.size
&& [...weekend].every(v => this.#days.has(v))
){
return 'weekends'
} else if(this.#days.size > 0){
return daylist
.filter( ({iso}) => this.#days.has(iso) )
Expand Down