cleaned to handle leap year properly

i'm sending this pull request, as i used this original logic for another project i forked (whiskerboard). in doing so, i noticed it didn't account for leap years. In either case, this should take leap years into consideration.