Created
December 22, 2019 11:10
-
-
Save alizadeh118/f374165745479ff267b2e7774ab7dfba to your computer and use it in GitHub Desktop.
تبدیل تاریخ هجری شمسی / جلالی / خورشیدی به هجری قمری
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// m: 1-12 | |
// d: 1-31 | |
const j2q = (y, m, d) => { | |
d = m > 6 ? (6 * 31) + ((m - 7) * 30) + d : ((m - 1) * 31) + d | |
let result = ((y - 1) * 365.2422 + d - 119) / 354.3670 | |
result = result.toString().split('.') | |
y = +result[0] + 1 | |
result = (('0.' + result[1]) * 12).toString().split('.') | |
m = +result[0] + 1 | |
d = +(('0.' + result[1]) * 29.530).toString().split('.')[0] + 1 | |
return {y,m,d} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
هشدار: محاسبات این تابع خیلی دقیق نیست و صرفا برای تست پیاده سازی شده است