Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/jalaali.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ describe("Jalaali", () => {
expect(yearRange).toHaveLength(4);
});

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

test.each`
format | expected
${"keyboardDate"} | ${"۱۳۹۸/۱۰/۱۱"}
Expand Down
4 changes: 4 additions & 0 deletions packages/jalaali/src/jalaali-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export default class MomentUtils extends DefaultMomentUtils {
return date.jMonth();
};

public setMonth = (date: Moment, month: number) => {
return date.clone().jMonth(month);
};

public getDaysInMonth = (date: Moment) => {
return date.daysInMonth();
};
Expand Down