Skip to content

Commit

Permalink
Hot fix for 12th month of the year
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Kasaaian committed Feb 20, 2024
1 parent 16aa443 commit 5b6e4d9
Show file tree
Hide file tree
Showing 8 changed files with 7,138 additions and 1,750 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
.idea
npm-debug.log
node_modules
test-app/*
test-app/*
package-lock.json
yarn.lock
36 changes: 36 additions & 0 deletions dist/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";

(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['../index'], factory);
} else if (typeof exports !== "undefined") {
factory(require('../index'));
} else {
var mod = {
exports: {}
};
factory(global.index);
global.undefined = mod.exports;
}
})(void 0, function (_require) {
"use strict";

var daysInMonth = _require.daysInMonth;
describe('daysInMonth', function () {
test('1st month should return 31', function () {
expect(daysInMonth('1', '1402')).toBe(31);
});
test('6th month should return 31', function () {
expect(daysInMonth('6', '1402')).toBe(31);
});
test('7th month should return 30', function () {
expect(daysInMonth('7', '1402')).toBe(30);
});
test('12th month should return 29 in non-leap year', function () {
expect(daysInMonth('12', '1402')).toBe(29);
});
test('12th month should return 30 in leap year', function () {
expect(daysInMonth('12', '1403')).toBe(30);
});
});
});
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.daysInMonth = undefined;
var _react2 = _interopRequireDefault(_react);
var _momentJalaali2 = _interopRequireDefault(_momentJalaali);
var _Days2 = _interopRequireDefault(_Days);
Expand Down Expand Up @@ -82,8 +83,11 @@
}
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
_momentJalaali2["default"].loadPersian([]);
var daysInMonth = function daysInMonth(month, year) {
if (month > 0 && month < 7) return 31;else if (month > 6 && month < 12) return 30;else if (month === 12 && _momentJalaali2["default"].jIsLeapYear(year)) return 30;else if (month === 12 && !_momentJalaali2["default"].jIsLeapYear(year)) return 29;
var daysInMonth = exports.daysInMonth = function daysInMonth(month, year) {
if (month > 0 && month < 7) return 31;
if (month > 6 && month < 12) return 30;
if (month == 12 && _momentJalaali2["default"].jIsLeapYear(year)) return 30;
if (month == 12 && !_momentJalaali2["default"].jIsLeapYear(year)) return 29;
};
function JDatePicker(props) {
var id = props.id,
Expand Down
Loading

0 comments on commit 5b6e4d9

Please sign in to comment.