Last active
July 13, 2021 12:28
-
-
Save hasanisaeed/e850a31ca53f186a5ceedf0a5c207b59 to your computer and use it in GitHub Desktop.
Convert Georgian to Shamsi(Jalali)
This file contains 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
// https://www.linkedin.com/posts/ppx1400_ppx-progprox-afyahyabrafyahyabraepahyagpaeb-activity-6820335516840546304-eHMZ | |
function GtoJ(a){ | |
var e,d,c; | |
var n,m,l; | |
var b,h; | |
var k; | |
var f; | |
var gdays=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
var jdays=[31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29] | |
function div(c,d){return Math.floor(c/d)} | |
e=a.split("/")[0]-1600; | |
d=a.split("/")[1]-1; | |
c=a.split("/")[2]-1; | |
b=365*e+div((e+3),4)-div((e+99),100)+div((e+399),400); | |
for(f=0;f<d;++f){ | |
b+=gdays[f] | |
} | |
if(d>1&&((e%4==0&&e%100!=0)||(e%400==0))){ | |
++b | |
} | |
b+=c; | |
h=b-79; | |
k=div(h,12053); | |
h%=12053; | |
n=979+33*k+4*div(h,1461); | |
h%=1461; | |
if(h>=366){ | |
n+=div((h-1),365); | |
h=(h-1)%365 | |
} | |
for(f=0;f<11&&h>=jdays[f];++f){ | |
h-=jdays[f] | |
} | |
m=f+1; | |
l=h+1; | |
return n+"/"+m+"/"+l; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment