<div dir="ltr">I have a script that does something if it's the last day of the month. To calculate the last day of the month I first used the following line that I ”stole” from somewhere:<div>LastDayOfMonth=$(date -d"-1 day 1 $(date -d'next month' +%b)" +'%d')<br></div><div><br></div><div>In this case, LastDayOfMonth should be 31 since it is August now, but it fails in two ways:</div><div>”$(date -d'next month' +%b)” returns ”okt”, since my locale is Swedish (October=oktober in Swedish, with all non-capital letters unless it's at the beginning of a sentence).<br></div><div>So I changed the whole line to:</div><div>LastDayOfMonth=$(date -d"-1 day 1 $(date -d'next month' +%F)" +'%d')<br></div><div>”date -d'next month' +%F” returns ”2015-10-01” which at least doesn't lead to an error, but this is still the second way everything fails: Next month is September, not october!<br></div><div><br></div><div>So my question is: Why does the followinghappen?</div><div><div>~$ date +%F</div><div>2015-08-31</div></div><div><div>~$ date -d'next month' +%F</div><div>2015-10-01</div><div>~$</div><div><br></div><div>Wouldn't rather the following happen?</div><div><div><div>~$ date +%F</div><div>2015-08-31</div></div><div><div>~$ date -d'next month' +%F</div><div>2015-09-01</div><div>~$</div></div></div></div><div><br></div><div>I can probably get around the problem altogether, but I still want to know of this is a bug or not, and if not, why…</div><div><br></div><div><br></div><div><div>Kind regards</div><div><br></div><div>Johnny Rosenberg</div></div><div><br></div></div>