I am having trouble automatically calculating the working days of different online stores that open at different days. The difficulty here is some of the stores open during the weekends. What i realized was JavaScript starts counting the days of the week from 0 which is a Sunday.
example
store A, WORKING_DAYS = Tue - Sun
store B, WORKING_DAYS = Mon - Fri
store C, WORKING_DAYS = Mon - Tue
store D, WORKING_DAYS = Fri - Mon
// 0 (sunday) - 6 (saturday) give day is thursay which is 4
// workdays fri - tues, ie 5 - 2 but current day is saturday and we
looking at positive values
if( dayStart < currentDay < dayEnd){
return(
<Text style={[styles.h4,styles.tag, {backgroundColor:'#4eae5c'}]}>open</Text>
)
}
if(currentDay) {
return(
<Text style={[styles.h4,styles.tag,
{backgroundColor:'red'}]}>closed</Text>
)
}
because Sunday returns 0 from JavaScript date, how do you find the interval between Friday and Monday