Skip to main content
save 3 more characters
Source Link
gildux
  • 421
  • 4
  • 8

bash and BSD date, 10096 bytes

As an alternative to Toby Speight's answer but using BSD implementation instead of GNU one

s=(1 2)
m="-v$2y -v$(($1+1))mv$1 -v+1m -v1d"
date $m -v-$((s[$(dates[`date $m +%w)]+1+%w`]+1))d +%A\ %eth | sed%eth|sed s/1th/1st/

It has the following limitations:

  • months can be integers only, not strings (October or sep for example)
  • separator is changed from / to blanks which is natural shell arguments separator

There's certainly room for tweaking.

bash and BSD date, 100 bytes

As an alternative to Toby Speight's answer but using BSD implementation instead of GNU one

s=(1 2)
m="-v$2y -v$(($1+1))m -v1d"
date $m -v-$((s[$(date $m +%w)]+1))d +%A\ %eth | sed s/1th/1st/

It has the following limitations:

  • months can be integers only, not strings (October or sep for example)
  • separator is changed from / to blanks which is natural shell arguments separator

There's certainly room for tweaking.

bash and BSD date, 96 bytes

As an alternative to Toby Speight's answer but using BSD implementation instead of GNU one

s=(1 2)
m="-v$2y -v$1 -v+1m -v1d"
date $m -v-$((s[`date $m +%w`]+1))d +%A\ %eth|sed s/1th/1st/

It has the following limitations:

  • months can be integers only, not strings (October or sep for example)
  • separator is changed from / to blanks which is natural shell arguments separator

There's certainly room for tweaking.

Source Link
gildux
  • 421
  • 4
  • 8

bash and BSD date, 100 bytes

As an alternative to Toby Speight's answer but using BSD implementation instead of GNU one

s=(1 2)
m="-v$2y -v$(($1+1))m -v1d"
date $m -v-$((s[$(date $m +%w)]+1))d +%A\ %eth | sed s/1th/1st/

It has the following limitations:

  • months can be integers only, not strings (October or sep for example)
  • separator is changed from / to blanks which is natural shell arguments separator

There's certainly room for tweaking.