samanzamani / PersianDate

Persian date for android
BSD 3-Clause "New" or "Revised" License
330 stars 40 forks source link

Wrong result using addDay() method #50

Closed ARNvoid closed 3 years ago

ARNvoid commented 3 years ago

below code return wrong result for dates(1400/02/28,1400/02/29,1400/02/30,1400/02/31,1400/04/31,etc) jump to other days seems that this days dose not exist

    PersianDate pDate = new PersianDate();
    pDate.setGrgYear(1400);
    pDate.setGrgMonth(2);
    pDate.setGrgDay(28);
    pDate.addDay(1);
    String finalDate = pDate.getGrgYear()+"/"+pDate.getGrgMonth()+"/"+pDate.getGrgDay();

also in second half of year 1400 some months has 31 days :) Thanks for your great job, pls fix it as soon as possible. 🙏

ARNvoid commented 3 years ago

Sorry my bad 🤦‍♂️ I was using gregorian mehods exept shamsi methods now fixed

    PersianDate pDate = new PersianDate();
    pDate.setShYear(1400);
    pDate.setShMonth(2);
    pDate.setShDay(28);
    pDate.addDay(1);
    String finalDate = pDate.getShYear()+"/"+pDate.getShMonth()+"/"+pDate.getShDay();