dmtrKovalenko / date-io

Abstraction over common javascript date management libraries
MIT License
727 stars 90 forks source link

Inconsistency in getMonth and setMonth Methods #660

Closed SoheilHasankhani closed 8 months ago

SoheilHasankhani commented 8 months ago

The getMonth method is currently working with the Jalali month, while the setMonth method operates with the Gregorian month. This inconsistency leads to a failure in the following simple test:

it("Jalaali -- setAndGetMonth", () => {
    const date = jalaaliUtils.date(TEST_TIMESTAMP);
    const newDate = jalaaliUtils.setMonth(date, 0);
    expect(jalaaliUtils.getMonth(newDate)).toBe(0);
});

The getDate method has been overridden to work with jDate:

public getMonth = (date: Moment) => {
    return date.jMonth();
};

However, the setDate method has not been adjusted to match this behavior. This inconsistency needs to be addressed to ensure the correct functioning of the library.

dmtrKovalenko commented 8 months ago

Does it only affect moment jalaali? Could you please submit a PR with a test to fix this behavior as you already did?

dmtrKovalenko commented 8 months ago

closed by #661