Rawox Posted June 12, 2009 Share Posted June 12, 2009 (edited) Hi, I'm makin a script that calculates the different between two times. I'm almost done... but I don't know how to do the months because months have different digits. (31, 30, 29, 28)... I tried it with _Date_Time_GetSystemTime () & _Date_Time_SystemTimeToDateTimeStr, _DateDiff and _DateDaysInMonth but I just can't figure it out Even my dad can't fix it expandcollapse popup#include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> $i = 0 $Top = 12 $Length = 130 $Height = 11 $Extraleft = 68 $sDate = "2008/11/23 18:00:00" $x = 0 $h = 1 ;hours $D = 1 ;Days $M = 1 ;Months $Y = 1 ;Years HotKeySet ( "{ESC}", "ExitProg" ) ;AdlibEnable ( "refresh", 5000 ) ;////////////////////////////////////////////////////////////////////// BASE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; $iDateCalcseconds = _DateDiff ( 's',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcminutes = _DateDiff ( 'n',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalchours = _DateDiff ( 'h',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcdays = _DateDiff ( 'D',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcweeks = _DateDiff ( 'w',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcmonths = _DateDiff ( 'M',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcyears = _DateDiff ( 'Y',"2008/11/23 18:00:00", _NowCalc ( ) ) ;////////////////////////////////////////////////////////////////////// BASE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; $GUI = GUICreate ( "Cas (L) Lizzy", 270, 218+50, @DesktopWidth/2-139, @DesktopHeight/2-145 ) $Copy = GUICtrlCreateButton ( "Copy", 190, 8, 70, 22 ) $ACopy = GUICtrlCreateButton ( "Copy...", 10, 188, 100, 22 ) $Refresh = GUICtrlCreateButton ( "Refresh", 110, 188, 75, 22 ) $Quit = GUICtrlCreateButton ( "Quit", 185, 188, 75, 22 ) $Year = GUICtrlCreateLabel ( "00", 11+$Extraleft, $Top, 22 ) $Month = GUICtrlCreateLabel ( "00", 33+$Extraleft, $Top, 22 ) $Day = GUICtrlCreateLabel ( "00", 54+$Extraleft, $Top, 22 ) $Hour = GUICtrlCreateLabel ( "00", 82+$Extraleft, $Top, 22 ) $Minute = GUICtrlCreateLabel ( "00", 99+$Extraleft, $Top, 22 ) ;///////////////////////////////////////////////////////////////// COMPILED TIME \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; $GetMinutes = _DateDiff ( "n", $sDate, _NowCalc ( ) ) GUICtrlSetData ( $Minute, $GetMinutes ) Do If GUICtrlRead ( $Minute ) > 60 Then GUICtrlSetData ( $Hour, $h ) $h += 1 $n = GUICtrlRead ( $Minute ) GUICtrlSetData ( $Minute, $n-60 ) EndIf Until GUICtrlRead ( $Minute ) > 0 And GUICtrlRead ( $Minute ) < 60 Do If GUICtrlRead ( $Hour ) > 24 Then GUICtrlSetData ( $Day, $D ) $D += 1 $h = GUICtrlRead ( $Hour ) GUICtrlSetData ( $Hour, $h-24 ) EndIf Until GUICtrlRead ( $Hour ) > 0 And GUICtrlRead ( $Hour ) < 24 GUISetState ( @SW_SHOW ) ;Do ==> MY 100st TRY OR SOMETHIN LIKE THAT ; $DaysinMonth = _DateDaysInMonth ( @YEAR, @MON-$x ) ; MsgBox ( 0, "lol", $DaysinMonth ) ; $x += 1 ;Until 1 = 2 ;GUICtrlRead ( $Day ) > 0 And GUICtrlRead ( $Day ) < $DaysinMonth ;////////////////////////////////////////////////////////////////////// GUI \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; GUISetState ( @SW_SHOW ) GUISetFont ( 14, 400 ) GUICtrlCreateLabel ( "/", 26+$Extraleft, 8, 5 ) GUICtrlCreateLabel ( "/", 47+$Extraleft, 8, 5 ) GUISetFont ( 12, 400 ) GUICtrlCreateLabel ( "-", 72+$Extraleft, 7, 5 ) GUISetFont ( 8.5, 400 ) GUICtrlCreateLabel ( "Together for:", 12, 12, 64 ) GUICtrlCreateLabel ( ":", 95+$Extraleft, 11, 3 ) ;//////////////////////////////////////////////////////////////////// DETAILED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; GUICtrlCreateGroup ( "Detailed Information", 10, 35, 250, 133+18 ) GUICtrlCreateLabel ( "Total Seconds:", 20, 55 ) GUICtrlCreateLabel ( "Total Minutes:", 20, 55+18 ) GUICtrlCreateLabel ( "Total Hours:", 20, 55+18*2 ) GUICtrlCreateLabel ( "Total Days:", 20, 55+18*3 ) GUICtrlCreateLabel ( "Total Weeks:", 20, 55+18*4 ) GUICtrlCreateLabel ( "Total Months:", 20, 55+18*5 ) GUICtrlCreateLabel ( "Total Years:", 20, 55+18*6 ) $TotalSeconds = GUICtrlCreateLabel ( $iDateCalcseconds, 120, 55, $Length, $Height ) $TotalMinutes = GUICtrlCreateLabel ( $iDateCalcminutes, 120, 55+18, $Length, $Height ) $TotalHours = GUICtrlCreateLabel ( $iDateCalchours, 120, 55+18*2, $Length, $Height ) $TotalDays = GUICtrlCreateLabel ( $iDateCalcdays, 120, 55+18*3, $Length, $Height ) $TotalWeeks = GUICtrlCreateLabel ( $iDateCalcweeks, 120, 55+18*4, $Length, $Height ) $TotalMonths = GUICtrlCreateLabel ( $iDateCalcmonths, 120, 55+18*5, $Length, $Height ) $TotalYears = GUICtrlCreateLabel ( $iDateCalcyears, 120, 55+18*6, $Length, $Height ) ;///////////////////////////////////////////////////////////////////// CHANGE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\; GUICtrlSetState ( $ACopy, $GUI_FOCUS ) GUISetState ( @SW_SHOW ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ACopy $Pos = WinGetPos ( "Cas (L) Lizzy" ) WinMove ( "Cas (L) Lizzy", "", $Pos[0], $Pos[1]-95 ) $Advanced = GUICreate ( "Advanced Copy", 275, 85, -1, $Pos[1]+165, -1, -1, $GUI ) $Copy = GUICtrlCreateButton ( "Copy", 10, 55, 255, 25 ) $RSeconds = GUICtrlCreateRadio ( "Seconds.", 10, 10 ) $RMinutes = GUICtrlCreateRadio ( "Minutes.", 10+70, 10 ) $RHours = GUICtrlCreateRadio ( "Hours.", 10+140, 10 ) $RDays = GUICtrlCreateRadio ( "Days.", 10+210, 10 ) $RWeeks = GUICtrlCreateRadio ( "Weeks.", 10, 10+20 ) $RMonths = GUICtrlCreateRadio ( "Months.", 10+70, 10+20 ) $RYears = GUICtrlCreateRadio ( "Years.", 10+140, 10+20 ) $RTotal = GUICtrlCreateRadio ( "Total.", 10+210, 10+20 ) GUICtrlSetState ( $RSeconds, $GUI_CHECKED ) GUICtrlSetState ( $Copy, $GUI_FOCUS ) GUISetState ( @SW_SHOW ) While 1 Switch GUIGetMsg() Case $Copy If GUICtrlRead ( $RSeconds ) = $GUI_CHECKED Then $WriteSeconds = GUICtrlRead ( $TotalSeconds ) ClipPut ( $WriteSeconds ) ElseIf GUICtrlRead ( $RMinutes ) = $GUI_CHECKED Then $WriteMinutes = GUICtrlRead ( $TotalMinutes ) ClipPut ( $WriteMinutes ) ElseIf GUICtrlRead ( $RHours ) = $GUI_CHECKED Then $WriteHours = GUICtrlRead ( $TotalHours ) ClipPut ( $WriteHours ) ElseIf GUICtrlRead ( $RDays ) = $GUI_CHECKED Then $WriteDays = GUICtrlRead ( $TotalDays ) ClipPut ( $WriteDays ) ElseIf GUICtrlRead ( $RWeeks ) = $GUI_CHECKED Then $WriteWeeks = GUICtrlRead ( $TotalWeeks ) ClipPut ( $WriteWeeks ) ElseIf GUICtrlRead ( $RMonths ) = $GUI_CHECKED Then $WriteMonths = GUICtrlRead ( $TotalMonths ) ClipPut ( $WriteMonths ) ElseIf GUICtrlRead ( $RYears ) = $GUI_CHECKED Then $WriteYears = GUICtrlRead ( $TotalYears ) ClipPut ( $WriteYears ) ElseIf GUICtrlRead ( $RTotal ) = $GUI_CHECKED Then MsgBox ( 0, "Error", "Still working on this" ) EndIf Case $GUI_EVENT_CLOSE GUIDelete ( $Advanced ) Sleep ( 300 ) WinMove ( "Cas (L) Lizzy", "", @DesktopWidth/2-139, @DesktopHeight/2-145 ) refresh() ExitLoop EndSwitch WEnd Case $Copy MsgBox ( 0, "lol", "lol" ) Case $Refresh refresh() Case $Quit Exit EndSwitch WEnd Func ExitProg() Exit EndFunc Func refresh() If Not WinActive ( "Advanced Copy" ) Then $iDateCalcseconds = _DateDiff ( 's',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcminutes = _DateDiff ( 'n',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalchours = _DateDiff ( 'h',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcdays = _DateDiff ( 'D',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcweeks = _DateDiff ( 'w',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcmonths = _DateDiff ( 'M',"2008/11/23 18:00:00", _NowCalc ( ) ) $iDateCalcyears = _DateDiff ( 'Y',"2008/11/23 18:00:00", _NowCalc ( ) ) GUICtrlDelete ( $TotalSeconds ) $TotalSeconds = GUICtrlCreateLabel ( $iDateCalcseconds, 120, 55, $Length, $Height ) GUICtrlDelete ( $TotalMinutes ) $TotalMinutes = GUICtrlCreateLabel ( $iDateCalcminutes, 120, 55+18, $Length, $Height ) GUICtrlDelete ( $TotalHours ) $TotalHours = GUICtrlCreateLabel ( $iDateCalchours, 120, 55+18*2, $Length, $Height ) GUICtrlDelete ( $TotalDays ) $TotalDays = GUICtrlCreateLabel ( $iDateCalcdays, 120, 55+18*3, $Length, $Height ) GUICtrlDelete ( $TotalWeeks ) $TotalWeeks = GUICtrlCreateLabel ( $iDateCalcweeks, 120, 55+18*4, $Length, $Height ) GUICtrlDelete ( $TotalMonths ) $TotalMonths = GUICtrlCreateLabel ( $iDateCalcmonths, 120, 55+18*5, $Length, $Height ) GUICtrlDelete ( $TotalYears ) $TotalYears = GUICtrlCreateLabel ( $iDateCalcyears, 120, 55+18*6, $Length, $Height ) EndIf EndFunc The one who makes it is my hero! .Rawox Edited June 13, 2009 by Rawox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 12, 2009 Moderators Share Posted June 12, 2009 Rawox,Look at _DateDiff in the Help file and use some basic maths.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rawox Posted June 12, 2009 Author Share Posted June 12, 2009 I am not really good with basic maths,, I tried this: GUICtrlSetData ( $Second, $iDateCalc ) $iMinute = 1 $iSecond = $iDateCalc Do If GUICtrlRead ( $Second ) > 60000 Then GUICtrlSetData ( $Minute, $iMinute ) $iMinute += 1 $Read = GUICtrlRead ( $Second ) GUICtrlSetData ( $Second, $Read-60000 ) EndIf Until GUICtrlRead ( $Second ) < 60000 I don't know It does not work. Link to comment Share on other sites More sharing options...
oMBRa Posted June 12, 2009 Share Posted June 12, 2009 why dont you look what Melba has already suggested? Link to comment Share on other sites More sharing options...
Rawox Posted June 12, 2009 Author Share Posted June 12, 2009 I've done that! But I don't get it. My english isn't really good and I am just 15 years old... Can someone make me an example or something so I get it too? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 12, 2009 Moderators Share Posted June 12, 2009 Rawox,An example of _DateDiff in days for your chosen date:#Include <Date.au3> $sDate = "2008/11/23 18:00:00" $Days = _DateDiff("D", $sDate, _NowCalc()) ConsoleWrite($Days & " Days" & @CRLF)At 15 you should be able to do enough basic maths to convert time periods. If not your career as a coder will be very frustrating as almost all coding (or programming) relies on that sort of simple calulation for anything more than initial "Hello World" type scripts.Give it a go yourself and come back if you have problems - and I do NOT mean in 5 minutes! ;-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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