Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
stacked26797yJust a guess, but...
I suppose 'index' is initially 0 (or equivalent). You increment it at the start of the loop, instead of at the end.
This id like 1-based indexing, so sumOfMonths[index - 1] will return the current month, which means:
sumOfDays == sumOfMonths[index - 1]
You're interested in the previous month, so you have to get the previous index and subtract 1 again. Hence sumOfMonths[index - 2] -
navitas29317y@stacked @Voxera @Chlodovechus @IcyTv
This is the module where this screenshot is from:
https://github.com/ishan-marikar/...
Our national identity card numbers are formatted in a way where you can calculate the date of birth and the gender. -
Voxera115857y@monkehparade the -2 is because you only subtract up to the sum of the previous month, not the current one and since the loop starts with index++ it will be one ahead of the current month when in the loop.
But you should clean up the if ... return true, false and only return the condition of the if ;)
Also, the month sum seems to be for a leap year but I could not see any handling of non leap year?
When you write code and forget to comment it, and then you come back and try to figure out why the heck you wrote certain parts of it.
Let this be a lesson for future me.
rant
why did i do this?