PersianDate icon indicating copy to clipboard operation
PersianDate copied to clipboard

Wrong month calculation

Open mohammadnr2817 opened this issue 10 months ago • 4 comments

Hello,

PersianDate().initJalaliDate(1404, 4, 1).addMonths(1) should return "1 mordad 1404" but returns "31 tir 1404" It seems a Java Calender mismatch issue with JalaliDate in addDate function.

Version: v.1.7.1

Image

mohammadnr2817 avatar Jun 25 '25 10:06 mohammadnr2817

Hello, This happens because the addition and subtraction operations in the library are internally performed based on the Gregorian calendar, and then converted to the Jalali date. As a result, operations like addMonths(1) may not return the expected value in the Jalali calendar, especially for dates near the end of the month

amirroid avatar Jul 21 '25 01:07 amirroid

@amirroid Thanks for additional notes. That's the exact issue I earlier mentioned. I need the fix for that but I don't know if this lib is still maintained by author or else I have to fix it myself.

mohammadnr2817 avatar Aug 23 '25 08:08 mohammadnr2817

@mohammadnr2817 I’m not sure if the library is still maintained by the author, but I’ve written a library for KMP before that doesn’t have this issue. You can check my repositories, there’s one called JalaliDate.

amirroid avatar Aug 23 '25 11:08 amirroid

Thank you @amirroid. I'll look into it.

mohammadnr2817 avatar Aug 25 '25 10:08 mohammadnr2817