amin84 Posted May 14, 2011 Share Posted May 14, 2011 I needed to convert Gregorian calendar to Solar calendar and I didn't find anything in AutoIt so I wrote my own. I'm pretty sure there are lots of better and more optimized formulas compared to mine. I still don't know how to calculate the name of the day (sat,sun,...). expandcollapse popup_miladi2shamsi(@MDAY, @MON, @YEAR) Func _miladi2shamsi($Dm, $Mm, $Ym) Dim $d, $p, $w, $mon, $u, $v, $rp, $x, $i, $Ys, $Ms, $P1, $D1, $Ds, $DateShamsi Local $d[12] = [20, 19, 20, 20, 21, 21, 22, 22, 22, 22, 21, 21] Local $p[12] = [11, 12, 10, 12, 11, 11, 10, 10, 10, 9, 10, 10] $u = 0 $rp = 0 If Mod($Ym, 4) = 0 Then $u = 1 If Mod($Ym, 100) = 0 And Mod($Ym, 400) <> 0 Then $u = 0 $Ys = $Ym - 622 $x = $Ys - 22 $x = Mod($x, 33) If Mod($x, 4) = 0 And $x <> 32 Then $rp = 1 $i = Not ($rp - 2) + Not ($u - 2) * 2 $x = 0 If $i = 0 And $Mm = 3 Then $x = 1 If $i = 0 Then $i = 3 $Ms = Mod((9 + $Mm), 13) If $Ms < 10 Then $Ms = $Ms + 1 $D1 = $d[$Mm - 1] If $i = 1 And $Mm > 2 Then $D1 = $D1 - 1 If $i = 2 And $Mm < 3 Then $D1 = $D1 - 1 $P1 = $p[$Mm - 1] If $i = 1 And $Mm > 2 Then $P1 = $P1 + 1 If $i = 1 And $Mm < 4 Then $P1 = $P1 + 1 If $Dm > 0 And $Dm <= $D1 Then $Ds = $P1 + $Dm + $x - 1 $x = 1 Else $Ds = $Dm - $D1 $Ms = $Ms + 1 If $Ms = 13 Then $Ms = 1 $x = 2 EndIf If (($Mm = 3 And $x = 2) Or $Mm > 3) Then $Ys = $Ys + 1 MsgBox(0,'',$Ys&'/'&$Ms&'/'&$Ds) EndFunc Link to comment Share on other sites More sharing options...
JScript Posted May 15, 2011 Share Posted May 15, 2011 I did not understand very well... but show! http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now