Skip to content

Commit

Permalink
Identify pure weekday/weekend day-of-week combos (#95)
Browse files Browse the repository at this point in the history
* update days of week combo labels

* small tweak to terms
  • Loading branch information
Nate-Wessel authored Jan 15, 2024
1 parent 71602c3 commit 016a8f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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

0 comments on commit 016a8f3

Please sign in to comment.