Bday_Info.au3

Last modified:   Monday, 12 May 2008

#cs
   This AutoIt script file was generated by Project Express 4.0.6.9 Apr 22 / 2008
   AutoIt Compiler Version: 		3.2.11.9
   Language:		English (US)
   Platform: 		All
   Author: 		George (GEOSoft) Gedye
   Company: 		
   E-Mail:		geog AT mvps DOT org
   ;
   Project Name: 		Born
   To Do List:
   ;
#ce
Opt ("TrayIconDebug", 1)
#Include <date.au3>
#Include<dialog.au3>
$mData = ""
For $I = 1 To 12
   $mData &= "|" & StringFormat("%02u", $I)
Next
$Gw = 560
$Gh = 580
$Ttl = "About Your Birth Date"
$Comb_Style = BitOr(0x00200000, 0x0003)
$Frm = GUICreate($ttl, $Gw, $Gh)
GUICtrlCreateLabel("Enter the year..", 20,10, 80, 20)
$Yr = GUICtrlCreateInput("", 100,10, 35)
$Lbl_M = GUICtrlCreateLabel("Select the Month", 155, 10, 90)
$mth = GUICtrlCreateCombo("", 245,10, 60, -1, $Comb_Style)
$Lbl_D = GUICtrlCreateLabel("Select the Day", 325, 10, 90)
$Day = GUICtrlCreateCombo("", 415,10, 40, -1, $Comb_Style)
GUICtrlSetData($Mth, $mData)
For $I = $Lbl_M To $Day
   GUICtrlSetState($I, 32)
Next
GUISetCoord(60, 50)
$Lbl_Data = GUICtrlCreateLabel("", -1, -1, $Gw - 120, 250)
GUICtrlSetFont($Lbl_Data, 10)
;GUICtrlSetBkColor(-1, 0xffffff)
$Lbl_Data2 = GUICtrlCreateLabel("", 20, 320, ($Gw/2)-50, 20)

GUICtrlSetFont($Lbl_Data2, 10)
;GUICtrlSetBkColor(-1, 0xFF0000)
$Btn_Clr = GUICtrlCreateButton("Reset", ($Gw/2) -30, $Gh -40, 60, 30)
GUISetState()

While 1
   If StringLen(GUICtrlRead($Yr)) < 4 Then
      Do
         Sleep(2)
         If GUIGetMsg() = -3 Then Exit
      Until StringLen(GUICtrlRead($Yr)) = 4
      GUICtrlSetState($mth, 336)
      GUICtrlSetState($Lbl_M, 80)
   EndIf
   Switch GUIGetMsg()
      Case - 3
         Exit
      Case $mth
         $dData = ""
         ;MsgBox(0, "TEST index", GetCurSel($mth))
         For $I = 1 To _DateDaysInMonth(GUICtrlRead($Yr), GUICtrlRead($mth))
            $dData &= "|" & StringFormat("%02u", $I)
         Next
         GUICtrlSetData($day, $dData)
         GUICtrlSetState($day, 336)
         GUICtrlSetState($Lbl_D, 80)
      Case $day
         $oData = ""
         For $I = $Yr -1 to $Day
            GUICtrlSetState($I, 144)
         Next
         Local $dY = GUICtrlRead($Yr), $dM = GUICtrlRead($mth), $dD = GUICtrlRead($day)
         WinSetTitle($Frm, "", $Ttl & "  " &  _DateMonthOfYear($dM, 0) & " " & $dD & ", " & $dY)
         If $dD = @Mday AND $dM = @Mon Then $oData &= "HAPPY BIRTHDAY!!" & @CRLF & @CRLF
         $oData &= "You were born on a "
         $astData = _Astrology_Symbols($dM, $dD)
         $oData &= _DateDayofWeek(_DateToDayOfWeek ($dY, $dM, $dD))
         If _DateIsLeapYear($dY) Then $oData &= "  (" & $dY & " was a Leap Year)"
         $bInfo = _Date_DaysLapsed($dY, $dM, $dD)
         $oData &=@CRLF & "You are " & $bInfo[0] & " years old." & @CRLF & "Your astrological sign is " & $astData[0] & @CRLF
         $oData &= "Your element is " & $astData[1] & @CRLF & @CRLF & "Time periods passed since your birth:" & @CRLF
         $oData &= @Tab & @Tab & $bInfo[1] & " years" & @CRLF & @Tab & @Tab & $bInfo[2] & " months" & @CRLF
         $oData &= @Tab & @Tab & $bInfo[3] & " weeks" & @CRLF & @Tab & @Tab & $bInfo[4] & " days" & @CRLF & @Tab & @Tab
         $oData &= $bInfo[5] & " hours" & @CRLF & @Tab & @Tab & $bInfo[6] & " minutes" & @CRLF & @Tab & @Tab & $bInfo[7] & _
               " seconds" & @CRLF
         $oData &= @CRLF & "There are " & _Date_DaysRemaining($dM, $dD) & " days remaining before your next birthday." & @CRLF & @CRLF
         GUICtrlSetData($Lbl_Data, $oData)
         $brData = _Date_BioRhythm($bInfo[4])
         $Lsp = 345
         GUICtrlSetData($Lbl_Data2, "Your Biorythms for today are :")
         $BioStart = GUICtrlCreateDummy()
         For $i = 0 To Ubound($brData) -1
            GUICtrlCreateLabel("   " & $brData[$i][0] & " = " & StringReplace($brData[$i][1], "-", " - ") & "%", 60, $Lsp, 160, 20)
            GUICtrlSetBkColor(-1, "0x" & $brData[$i][2])
            If $i = 2 OR $i = 3 OR $i = 6 Then GUICtrlSetColor(-1, "0xFFFFFF")
            GUICtrlSetFont(-1, 10)
            $Lsp += 25
         Next
         CreateChart(($Gw/2) +30,320,230,200,2,0xcaeaff, 0x7276a6)
         $BioEnd = GUICtrlCreateDummy()
         GUICtrlSetState($Btn_Clr, 256)
      Case $Btn_Clr
         For $I = $Yr -1 to $Yr
            GUICtrlSetState($I, 80)
         Next
         For $I = $Lbl_M To $Day
            GUICtrlSetState($I, 32)
         Next
         GUICtrlSetState($Yr, 256)
         GUICtrlSetData($Yr, "")
         GUICtrlSetData($day,"")
         GUICtrlSetData($Mth, $mData, "")
         GUICtrlSetData($Lbl_Data, "")
         GUICtrlSetData($Lbl_Data2, "")
         For $I = $BioStart To $BioEnd
            GUICtrlDelete($i)
         Next
         WinSetTitle($Frm, "", $ttl)
   EndSwitch
Wend

Func _Astrology_Symbols($iMth, $iDay) ;;Return Astrological Data of a Date
   local $aData[2][13] = [ ["","Capricorn", "Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius"] _
         , ["","Earth", "Air", "Water", "Fire", "Earth", "Air", "Water", "Fire", "Earth", "Air", "Water", "Fire"]]
   $rSign = $iMth
   Switch $iMth
      Case 1, 3 ; Capricorn
         If $iDay > 19 Then $rSign += 1
      Case 2 ; Aquarius
         If $iDay > 17 Then $rSign += 1
      Case 4, 5, 11 ; Aries
         If $iDay > 20 Then $rSign += 1
      Case 6 ;Gemini
         If $iDay > 22 Then $rSign += 1
      Case 12 ; Sagittarius
         If $iDay > 21 Then $rSign = 1
      Case Else
         If $iDay > 21 Then $rSign += 1
   EndSwitch
   local $Sg = $aData[0][$rSign], $El = $aData[1][$rSign], $oData[2] = [$Sg, $El]
   Return $oData
EndFunc    ;<===> _Astrology_Symbols()

Func _Date_DaysLapsed($nYr, $nMth, $nDay)
   Local $I, $cMth = $nMth, $aDays = _DateDaysInMonth($nYr, $nMth) - $nDay, $aYrs = @Year - ($nYr + 1), $aMths = $aYrs * 12
   Local $dDiff = (_DateDaysInMonth($nYr, $nMth) - $nDay) + @Mday
   $aMths += Round((12 - ($nMth)) + @Mon -1 + ($dDiff/30), 2)
   $dYrs = Round($aMths/12, 2)
   $nMth += 1
   For $I = $nYr to @Year
      Do
         $aDays += _DateDaysInMonth($I, $nMth)
         $nMth += 1
         If $nMth = @Mon -1 AND $I = @Year Then ExitLoop(2)
         If $nMth >12 Then $nMth = 12
      Until $nMth = 12
      $nMth = 1
   Next
   $aDays += @Mday
   $aHrs = (($aDays -1) *24) + @Hour
   $aMin = ($aHrs *60) + @Min
   $aSec = ($aMin * 60) + @Sec
   If StringInStr($aMths, ".") Then
      $dMths = StringLeft($aMths, StringInStr($aMths, ".") -1)
      $aMths = _Number_AddSep(Int($dMths)) & StringMid($aMths, StringInStr($aMths, "."))
   Else
      $aMths = _Number_AddSep(Int($aMths))
   EndIf
   $aWks = Round($aDays/7, 2)
   If StringInStr($aWks, ".") Then
      $dWks = StringLeft($aWks, StringInStr($aWks, ".") -1)
      $aWks = _Number_AddSep(Int($dWks)) & StringMid($aWks, StringInStr($aWks, "."))
   Else
      $aWks = _Number_AddSep(Int($aWks))
   EndIf
   $aDays = _Number_AddSep(Int($aDays))
   $aHrs = _Number_AddSep(Int($aHrs))
   $aMin = _Number_AddSep(Int($aMin))
   $aSec = _Number_AddSep(Int($aSec))
   If $cMth = @Mon AND $nDay = @Mday Then $aYrs += 1
   Local $oArray [8] = [$aYrs, $dYrs, $aMths, $aWks, $aDays, $aHrs, $aMin, $aSec]
   Return $oArray
EndFunc    ;<===> _Date_DaysLapsed()

Func _Date_DaysRemaining($iMth, $iDay, $cYr = 0)
   Local $bDate, $cDate, $rDays = 0, $dDiff, $I
   $wYears = ($cYr-1) - (@Year)
   If ($wYears = 0 OR $wYears = 1) AND @Mon < $iMth Then $wYears += 1
   If $wYears > 0 Then
      For $y = @Year + 1 To @Year + $wYears
         For $I = 1 To 12
            $rDays += _DateDaysInMonth($y, $i)
         Next
      Next
      $cYr = 0
   EndIf
   If $cYr = 0 Then $cYr = @Year
   If StringLeft(_DateDiff("D", StringFormat("%u/%02u/%02u", $cYr, @Mon, @Mday), StringFormat("%s/%02u/%02u", $cYr, $iMth, $iDay)), 1) = "-" Then
      $cYr += 1
      For $I = @Mon to 12
         $rDays += _DateDaysInMonth($cYr, $i)
      Next
      If $iMth >= 2 Then
         For $i = 1 To $iMth-1
            $rDays += _DateDaysInMonth($cYr+1, $i)
         Next
      EndIf
      If (NOT _DateIsLeapYear($cYr)) AND $iMth = 2 AND $iDay = 29 Then $rDays -= 1
   Else
      $cMth = @Mon
      For $i = $cMth To $iMth-1
         $rDays += _DateDaysInMonth(@Year, $i)
      Next
      If $I > 12 Then $I = 1
   EndIf
   $dDiff = ($rDays - @Mday) + $iDay
   Return $dDiff
EndFunc    ;<===> _Date_DaysRemaining()

Func _Number_AddSep($iVal, $sSep = ",")
   If (NOT StringIsInt($iVal)) AND (NOT StringIsFloat($iVal)) Then Return SetError(1) ;; $iVal must be an Integer or a Float
   Local $dVal = ""
   If StringInStr($iVal, ".") Then
      $dVal = StringMid($iVal, StringInStr($iVal, "."))
      $iVal = StringLeft($iVal, StringInStr($iVal, ".") -1)
   EndIf
   Local $oVal = ""
   $cArray = StringSplit($iVal,"")
   For $I = Ubound($cArray)-3 to 1 step -3
      $cArray[$I] = $sSep & $cArray[$I]
   Next
   For $I = 1 To Ubound($cArray)-1
      $oVal &= $cArray[$I]
   Next
   If StringLeft($oVal, 1) = $sSep Then $oVal = StringTrimLeft($oVal, 1)
   Return $oVal & $dVal
EndFunc    ;<===> _Number_AddSep()

Func _Date_BioRhythm($aDays)
   $aDays = StringReplace(StringStripWS($aDays, 8), ",", "")
   If StringInStr($aDays, ".") Then $aDays = Round($aDays, 0)
   $pi = 3.14159265358979323846264338328
#cs
      Score = 100 * sin ( 2*PI*(180/PI) *(Age in Days / Cycle Length))
      EXAMPLE: Physical curve for somebody, who is 10000 days old today:
      100 * sin ( 360 *(10000 / 23)) = 97%
      Cycle lengths (* indicates primary cycles)
      Physical * 23 days
      Emotional * 28 days
      Intellectual * 33 days
      Spiritual  53 days
      Awareness 48 days
      Aesthetic 43 days
      Intuition 38 days
      Biorhythms Repeat
      The primary curves will have the same state like birth exactly 23*28*33 = 21252 days after birth again.
      This will be at the age of 58 years, 2 months and about 7 days depending on the position of the leap years and length of the month.
#ce
#cs
   $pScore = Round(100 * sin(360*($aDays /23)), 2)
   $eScore = Round(100 * sin(360*($aDays /28)), 2)
   $iScore = Round(100 * sin(360*($aDays /33)), 2)
   $sScore = Round(100 * sin(360*($aDays /53)), 2)
   $aScore = Round(100 * sin(360*($aDays /48)), 2)
   $aScore2 = Round(100 * sin(360*($aDays /43)), 2)
   $iScore2 = Round(100 * sin(360*($aDays /38)), 2)
#ce
   $pScore = Round(100*sin(2*$pi*(180/$pi) * ($aDays/23)), 2)
   $eScore = Round(100*sin(2*$pi*(180/$pi) * ($aDays/28)), 2)
   $iScore = Round(100*sin(2*$pi*(180/$pi) * ($aDays/33)), 2)
   $sScore = Round(100*sin(2*$pi*(180/$pi) * ($aDays/53)), 2)
   $aScore = Round(100*sin(2*$pi*(180/$pi) * ($aDays/48)), 2)
   $aScore2 = Round(100*sin(2*$pi*(180/$pi) * ($aDays/43)), 2)
   $iScore2 = Round(100*sin(2*$pi*(180/$pi) * ($aDays/38)), 2)
   Dim $bArray[7][3] = [ ["Physical",$pScore,"4ab548"], ["Emotional",$eScore,"6ccfff"], ["Intellectual",$iScore,"a657a6"], _
      ["Spiritual", $sScore,"7172c5"], ["Awareness",$aScore,"ffbfc1"], ["Aesthetic", $aScore2,"f9d862"], ["Intuition",$iScore2,"8b3b3a"] ]
   ;_Bio_GetChart($aDays,4)
   Return $bArray
EndFunc    ;<===> _Date_BioRhythm()

Func CreateChart($Chart_x, $Chart_y, $Chart_w, $Chart_h, $cLnsz, $cBkclr=Default, $chart_Lclr= 0x000000, $mPts = 8)
   $vCenter = $Chart_y + ($Chart_h/2)
   $hL_pos = $vCenter - 1
   $Mrkrs = $Chart_h/ $mPts
   _GUI_CreateRect($Chart_x, $Chart_y -2, $Chart_w, $Chart_h +4, $cLnsz, $cBkclr, $chart_Lclr); <<== Top and bottom borders are max val and min val
   _GUI_Line_H($Chart_x, $hL_pos, $Chart_w, 2, $chart_Lclr);; <<=== Center line (0%)
   For $I = 1 To $mPts -1
      _GUI_Line_H($Chart_x, $Chart_y + $Mrkrs*$I, $Chart_w, 1, $chart_Lclr)
   Next
   $Bstart = $Chart_x+10
   $bWidth = 30
   For $I = 0 To UBound($brData)-1
      $cClr = StringFormat("0x%s",$brData[$I][2])
      _Chart_CreateBar($Bstart, $vCenter, $brData[$I][1], $cClr, $bWidth)
      $Bstart += $bWidth
   Next
EndFunc   ;<==> CreateChart()

Func GetCurSel($H_Combobox)
   If IsHWnd ($H_Combobox) Then
      Local $A_Ret = DllCall ("user32.dll", "int", "SendMessage", "hwnd", $H_Combobox, "int", 0x147, "int", 0, "int", 0)
      Return $A_Ret[0]
   Else
      Return GUICtrlSendMsg ($H_Combobox, 0x147, 0, 0)
   EndIf
EndFunc    ;<===> GetCurSel()

;;============= End of Script ============