diff --git a/README.md b/README.md index aa15dc1..87000cb 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,13 @@ Convert Jalaali calendar date to javascript Date object by giving Jalaali year, ```js jalaali.jalaaliToDateObject(1400, 4, 30) // new Date(2021, 6, 21) ``` +### jalaaliToTimestamp(jy, jm, jd, millisecond = true) + +Convert Jalaali calendar date to Timestamp. + +```js +jalaali.jalaaliToTimestamp(1400, 4, 30) // 1626809400000 +``` ## License diff --git a/index.js b/index.js index 2c06d94..4449cce 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ module.exports = , g2d: g2d , d2g: d2g , jalaaliToDateObject: jalaaliToDateObject + , jalaaliToTimestamp: jalaaliToTimestamp } /* @@ -314,4 +315,16 @@ function mod(a, b) { gregorianCalenderDate.gm - 1, gregorianCalenderDate.gd ); +} + +/** + * Convert Jalaali calendar dates to Timestamp + * @param {number} jy jalaali year + * @param {number} jm jalaali month + * @param {number} jd jalaali day + * @param {boolean} [millisecond=true] calculate millisecond + * @returns Timestamp + */ +function jalaaliToTimestamp(jy, jm, jd, millisecond = true) { + return jalaaliToDateObject(jy, jm, jd).getTime() / (millisecond ? 1 : 1000); } \ No newline at end of file