Jump to content
Sign in to follow this  
Rawox

Getting Total Time?

Recommended Posts

Rawox

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??

#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

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Rawox

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.