persian-date-validate
Version:
Validate a Persian date
1 lines • 951 B
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { getDaysInPersianMonth } from \"persian-leap\";\r\n\r\n/**\r\n * Validate a Persian date.\r\n * @param year The year\r\n * @param month The month (1-12)\r\n * @param day The day\r\n * @returns `true` if the date is valid, `false` otherwise.\r\n */\r\nexport function isPersianDateValid(year: number, month: number, day: number): boolean {\r\n\tif (year < 1) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (month < 1 || month > 12) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tconst daysInMonth = getDaysInPersianMonth(year, month);\r\n\tif (day < 1 || day > daysInMonth) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n"],"names":["year","month","day","daysInMonth","getDaysInPersianMonth"],"mappings":"kEASmCA,EAAcC,EAAeC,GAC/D,GAAIF,EAAO,EACV,OAAO,EAGR,GAAIC,EAAQ,GAAKA,EAAQ,GACxB,OAAO,EAGR,IAAME,EAAcC,EAAqBA,sBAACJ,EAAMC,GAChD,QAAIC,EAAM,GAAKA,EAAMC,EAKtB"}