Rawox Posted April 25, 2009 Share Posted April 25, 2009 Hi! If you take a look at my script, you'll see that the above part is already working. But the part at the bottom doesn't It calculates how many minutes (Last input) are already past since the date ("2008/11/23 18:34:00"), But I want it to a max of 60 and when it overscribes that, it needs to add an hour, like on a digital clock. It also needs to do that when it is over 24 hours, and the max number of months etc. It would also be cool that it is possible to check how many days there are in a month and of it is a leapyear... Anyone?? expandcollapse popup#include <Date.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> $iDateCalcYears = _DateDiff( 'Y',"2008/11/23 18:34:00",_NowCalc()) ;years $iDateCalcMonts = _DateDiff( 'M',"2008/11/23 18:34:00",_NowCalc()) ;months $iDateCalcWeeks = _DateDiff( 'w',"2008/11/23 18:34:00",_NowCalc()) ;weeks $iDateCalcDays = _DateDiff( 'D',"2008/11/23 18:34:00",_NowCalc()) ;days $iDateCalcHours = _DateDiff( 'h',"2008/11/23 18:34:00",_NowCalc()) ;hours $iDateCalcMinutes = _DateDiff( 'n',"2008/11/23 18:34:00",_NowCalc()) ;minutes $iDateCalcSeconds = _DateDiff( 's',"2008/11/23 18:34:00",_NowCalc()) ;seconds GUICreate ( "Testing", 200, 280 ) GUICtrlCreateLabel ( "StartDate: 2008/11/23 18:34:00", 10, 10 ) GUICtrlCreateLabel ( "Jaar, of", 95, 34 ) GUICtrlCreateLabel ( "Maanden, of", 95, 59 ) GUICtrlCreateLabel ( "Weken, of", 95, 84 ) GUICtrlCreateLabel ( "Dagen, of", 95, 109 ) GUICtrlCreateLabel ( "Uren, of", 95, 134 ) GUICtrlCreateLabel ( "Minuten, of", 95, 159 ) GUICtrlCreateLabel ( "Seconden.", 95, 184 ) $Years = GUICtrlCreateInput ( "", 10, 30, 80, 20, $ES_RIGHT ) $Months = GUICtrlCreateInput ( "", 10, 55, 80, 20, $ES_RIGHT ) $Weeks = GUICtrlCreateInput ( "", 10, 80, 80, 20, $ES_RIGHT ) $Days = GUICtrlCreateInput ( "", 10, 105, 80, 20, $ES_RIGHT ) $Hours = GUICtrlCreateInput ( "", 10, 130, 80, 20, $ES_RIGHT ) $Minutes = GUICtrlCreateInput ( "", 10, 155, 80, 20, $ES_RIGHT ) $Seconds = GUICtrlCreateInput ( "", 10, 180, 80, 20, $ES_RIGHT ) GUICtrlSetData ( $Years, $iDateCalcYears ) GUICtrlSetData ( $Months, $iDateCalcMonts ) GUICtrlSetData ( $Weeks, $iDateCalcWeeks ) GUICtrlSetData ( $Days, $iDateCalcDays ) GUICtrlSetData ( $Hours, $iDateCalcHours ) GUICtrlSetData ( $Minutes, $iDateCalcMinutes ) GUICtrlSetData ( $Seconds, $iDateCalcSeconds ) GUICtrlCreateGroup ( "Totaal", 10, 210, 180, 50 ) GUICtrlCreateLabel ( "-", 55, 232 ) GUICtrlCreateLabel ( "-", 85, 232 ) GUICtrlCreateLabel ( "-", 150, 232 ) $TYears = GUICtrlCreateInput ( "0000", 20, 230, 32, 20, $ES_CENTER ) $TMonths = GUICtrlCreateInput ( "00", 60, 230, 22, 20, $ES_CENTER ) $TDays = GUICtrlCreateInput ( "00", 90, 230, 22, 20, $ES_CENTER ) $THours = GUICtrlCreateInput ( "00", 125, 230, 22, 20, $ES_CENTER ) $TMinutes = GUICtrlCreateInput ( "00", 155, 230, 22, 20, $ES_CENTER ) GUICtrlSetData ( $TYears, $iDateCalcYears ) GUICtrlSetData ( $TMonths, $iDateCalcMonts ) GUICtrlSetData ( $TDays, $iDateCalcDays ) GUICtrlSetData ( $THours, $iDateCalcHours ) GUICtrlSetData ( $TMinutes, $iDateCalcMinutes ) GUISetState ( ) While 1 If GUICtrlRead ( $TMinutes ) > 60 Then $THours = $THours + 1 EndIf $msg = GUIGetMsg ( ) Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 25, 2009 Moderators Share Posted April 25, 2009 Rawox,You have the total number of seconds, so I suggest repeated divisions by 60, 60, 24, etc. There are a number of functions (like _DateDaysInMonth and _DateIsLeapYear) to help with the tricky bits.Have you searched the forum? I am sure this must have been done before - or something pretty close to it.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 April 25, 2009 Author Share Posted April 25, 2009 Well, I do know these functions. The problem is that I don't know how to use them... Could someone make a working function for the minutes (to hours) That's all I need. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 25, 2009 Moderators Share Posted April 25, 2009 Rawox,This converts minutes to hours (and minutes) as you requested:$Mins = 75 $Hours = Int($Mins / 60) $Mins_Display = $Mins - ($Hours * 60) MsgBox(0, "", $Hours & ":" & $Mins_Display)You need to apply the same principle to each change of period from seconds to years - obviously the factor will change depending on the relationship. ;-)As I mentioned above, you will need to do a bit of clever algebra to get the correct days in the months and to compensate for leapyears, but the _Date.... functions will help here.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