Yes, someone actually did this and I found it running on our server

You are viewing a single thread.
View all comments
30 points
*
weekend = day_of_week in (“sat”, “sun”)

As a bonus this completely sidesteps the issue of what day is 0 or 1.

permalink
report
reply
6 points

Until some idiot sends in “Sunday” as days of the week…

permalink
report
parent
reply
5 points
*

/^(sun|sat)/i.test(day_of_week)

👍

permalink
report
parent
reply
9 points

Ah yes the ole sunweday. My favorite day of the weekend.

permalink
report
parent
reply
1 point

looks good lgtm

permalink
report
parent
reply
1 point

yeah I like having an array of days that are weekend days then testing if the day is in the array. can change what days are considered weekend if we go to a three day weekend and it reads really well. I hate massive if statements

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.1K

    Monthly active users

  • 953

    Posts

  • 36K

    Comments