FaridAgl Posted May 4, 2014 Share Posted May 4, 2014 Maybe someone found it useful: expandcollapse popupFunc GregorianToSolar($iYear = @YEAR, $iMonth = @MON, $iDay = @MDAY) Local Const $aiDays[] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] Local $iDayOfYear = 0 For $i = 1 To $iMonth - 1 $iDayOfYear += $aiDays[$i - 1] Next $iDayOfYear += $iDay If ((Mod($iYear, 4) = 0 And Mod($iYear, 100) <> 0) Or (Mod($iYear, 400) = 0)) Then If ($iMonth > 2) Then $iDayOfYear += 1 EndIf If ($iDayOfYear <= 79) Then If (Mod($iYear - 1, 4) = 0) Then $iDayOfYear += 11 Else $iDayOfYear += 10 EndIf $iYear -= 622 If (Mod($iDayOfYear, 30) = 0) Then $iMonth = $iDayOfYear / 30 + 9 $iDay = 30 Else $iMonth = $iDayOfYear / 30 + 10 $iDay = Mod($iDayOfYear, 30) EndIf Else $iYear -= 621 $iDayOfYear -= 79 If ($iDayOfYear <= 186) Then If (Mod($iDayOfYear, 31) = 0) Then $iMonth = $iDayOfYear / 31 $iDay = 31 Else $iMonth = $iDayOfYear / 31 + 1 $iDay = Mod($iDayOfYear, 31) EndIf Else $iDayOfYear -= 186 If (Mod($iDayOfYear, 30) = 0) Then $iMonth = $iDayOfYear / 30 + 6 $iDay = 30 Else $iMonth = $iDayOfYear / 30 + 7 $iDay = Mod($iDayOfYear, 30) EndIf EndIf EndIf Return StringFormat("%u-%02u-%02u", $iYear, $iMonth, $iDay) EndFunc Jangal 1 http://faridaghili.ir Link to comment Share on other sites More sharing options...
UEZ Posted May 4, 2014 Share Posted May 4, 2014 I like the idea that "new year" is on 21st of March when winter is over and spring begins.Seems to calculate Norūz properly.Br,UEZ Jangal 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
FaridAgl Posted May 5, 2014 Author Share Posted May 5, 2014 (edited) I like the idea that "new year" is on 21st of March when winter is over and spring begins. You know, it's somehow the best part of it. Seems to calculate Norūz properly. Yeap, exactly, the first 13 days of new year (which starts by the first day of spring) is called Norūz. The above function converts a Gregorian date to a Solar date, for example: ConsoleWrite(GregorianToSolar(1992, 02, 01) & @CRLF) ;Outputs: 1370-11-12, which is my birthday ^_^ Edited May 5, 2014 by D4RKON3 http://faridaghili.ir 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