system.date.getDate, please help me understand

I never understood why, but you'll need to adjust for that.
Just remove 1 from your month.