« first day (4499 days earlier)      last day (459 days later) » 

3:36 PM
Here is the solution it gave me for that AIX question lol
#!/bin/sh

current_month=$(date +%m)
current_year=$(date +%Y)

if [ $current_month -eq 1 ]; then
  prev_month=12
  prev_year=$((current_year - 1))
else
  prev_month=$((current_month - 1))
  prev_year=$current_year
fi

case $prev_month in
  01) prev_month_name="January";;
  02) prev_month_name="February";;
  03) prev_month_name="March";;
  04) prev_month_name="April";;
  05) prev_month_name="May";;
  06) prev_month_name="June";;
  07) prev_month_name="July";;
  08) prev_month_name="August";;
  09) prev_month_name="September";;
Which IMO isn't that terrible
 
3:56 PM
except it doesn't work; when date +%m gives 02 for example, the $((02 - 1)) assigns "1" to prev_month, so the case statement pieces shouldn't have the leading 0's
 
yeah I figured that would have to be modified
I think I've yet to see it spit out completely working code but it's usually close enough to easily fix
 
@jesse_b That's what makes it so bad for the site: it's plausible-looking BS.
Pure BS would have been easier to handle.
 
@terdon I dunno, I'm still here after all these years
 
That's because you're 100% pure BS! :P
(I always get a bit paranoid about that, so in case the smiley wasn't clear, that was of course a joke!)
 
no worries, I have a long history of chop busting
 
4:33 PM
The thing that is wrong with this, as with many other answers that ChatGPT is coming up with, is that the approach is wrong. You should not try to do date computations yourself, even if it is with the resolution of a month. This is why Stéphane's answer in the duplicate says to use virtually any other tool to do the calculation for you before you try to do it yourself.
@JeffSchaller Also, as usual, with current_month=09, that test will fail with bash: 09: value too great for base (error token is "09")
 

« first day (4499 days earlier)      last day (459 days later) »