Necromorph Posted April 7, 2010 Share Posted April 7, 2010 (edited) i have an idea of some functionality i want, but i think that this one may be a bit out of my grasp, it may not even be possible.... i want to have a datetimepicker that the is in the format of 'hh:mm tt' and have the arrow controls make it step in 15 minute intervals ie: 04:00 pm, 04:15 pm, 04:30 pm and so on, just looking for some ideas, or if this even possible. thanks. Edited April 7, 2010 by redLabel Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2010 Moderators Share Posted April 7, 2010 (edited) redLabel,Does this help: expandcollapse popup#include <GUIConstantsEx.au3> #include <DateTimeConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hDate = GUICtrlCreateDate("", 10, 10, 200, 20, $DTS_TIMEFORMAT) GUISetState() $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW $sStyle = "HH:mm tt" GUICtrlSendMsg($hDate, $DTM_SETFORMAT_, 0, $sStyle) $sTime = GUICtrlRead($hDate) $iCurrMins = Number(StringMid($sTime, 4, 2)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $sTime = GUICtrlRead($hDate) $sHour = StringMid($sTime, 1, 2) $iMins = Number(StringMid($sTime, 4, 2)) Switch $iMins Case 1 To 14 If $iMins > $iCurrMins Then $iMins = 15 Else $iMins = 0 EndIf GUICtrlSetData($hDate, "2010/04/07 " & $sHour & ":" & StringFormat("%02i", $iMins) & ":00") Case 16 To 29 If $iMins > $iCurrMins Then $iMins = 30 Else $iMins = 15 EndIf GUICtrlSetData($hDate, "2010/04/07 " & $sHour & ":" & StringFormat("%02i", $iMins) & ":00") Case 31 To 44 If $iMins > $iCurrMins Then $iMins = 45 Else $iMins = 30 EndIf GUICtrlSetData($hDate, "2010/04/07 " & $sHour & ":" & StringFormat("%02i", $iMins) & ":00") Case 46 To 59 If $iCurrMins = 0 Then $iCurrMins = 60 If $iMins > $iCurrMins Then $iMins = 0 Else $iMins = 45 EndIf GUICtrlSetData($hDate, "2010/04/07 " & $sHour & ":" & StringFormat("%02i", $iMins) & ":00") EndSwitch $iCurrMins = $iMins WEndAt the moment, only the "up" arrow of the up/down works (because of the way I have constructed the Switch) - I am still trying to solve that. All fixed - at the expense of a more complicated Switch!M23Edit: New code. Edited April 7, 2010 by Melba23 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...
Necromorph Posted April 7, 2010 Author Share Posted April 7, 2010 thanks much, you rock! it will take some implementing into my script, but i will make it work!!! thanks again.! Link to comment Share on other sites More sharing options...
Necromorph Posted August 12, 2010 Author Share Posted August 12, 2010 (edited) i know this is old, and it has been on the back burner for me for some time now, but i got it resolve, and very easily as well, the issue with the above solution was that it didn't handle the the am/pm switch very well, ie: from 11:56 am should round up to 12:00 pm, but it didnt work like that, and it always rounded down. ie: 11:56 am would round down to 11:45 am. anyway, now that it doesn't work, but just not how i wanted it to work. so here is how i did it, which i think all the bugs are worked out of. expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIDateTimePicker.au3> #include <DateTimeConstants.au3> #include <Date.au3> $mainForm = GUICreate("15min step test", 200, 200) GUISetState() $time = GUICtrlCreateDate('', 25, 25, 150, -1, $dts_timeformat) $timeHandle = GUICtrlGetHandle($time) _GUICtrlDTP_SetFormat($timeHandle, 'hh:mm tt') $buttonTest = GUICtrlCreateButton("test", 25, 75, 75) While 1 $msg = GUIGetMsg() Switch $msg Case $gui_event_close Exit Case $buttonTest $testTime = GUICtrlRead($time) GUICtrlSetData($time, _NowCalcDate() & ' ' & _15minStep()) EndSwitch WEnd Func _15minStep() $hour = Number(StringLeft(GUICtrlRead($time), 2)) $min = Number(StringTrimLeft(StringTrimRight(GUICtrlRead($time), 3), 3)) $am_pm = StringRight(GUICtrlRead($time), 2) Select Case $min < 07.5 $min = 0 If $am_pm = "PM" and $hour <> 12 Then $hour = $hour + 12 EndIf Case $min < 22.5 $min = 15 If $am_pm = "PM" and $hour <> 12 Then $hour = $hour + 12 EndIf Case $min < 37.5 $min = 30 If $am_pm = "PM" and $hour <> 12 Then $hour = $hour + 12 EndIf Case $min < 52.5 $min = 45 If $am_pm = "PM" and $hour <> 12 Then $hour = $hour + 12 EndIf Case $min > 52.5 $min = 0 If $hour = 11 and $am_pm = "PM" Then $hour = 00 $am_pm = "AM" ElseIf $hour = 12 and $am_pm = "AM" Then $hour = 01 $am_pm = "AM" Else Switch $am_pm Case "AM" $hour = $hour + 1 Case "PM" $hour = $hour + 13 EndSwitch EndIf EndSelect Return $hour & ":" & $min & ' ' & $am_pm EndFunc but again, thanks for all the help. Edited August 13, 2010 by redLabel Link to comment Share on other sites More sharing options...
Spiff59 Posted August 12, 2010 Share Posted August 12, 2010 (edited) Does this do the same thing as your last example? Func _15minStep() Local $worktime = GUICtrlRead($time) $hour = StringLeft($worktime, 2) $min = StringMid($worktime, 4, 2) $am_pm = StringRight($worktime, 2) If $hour = 12 then $hour = "00" If $am_pm = "PM" Then $hour += 12 $min = Int(($min + 7.5) / 15) * 15 If $min = 60 Then $min = 0 $hour += 1 If $hour = 24 Then $hour = "00" EndIf Return $hour & ":" & $min & " " EndFunc Edit: Actually, it didn't, but should now. Edited August 12, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
Necromorph Posted August 13, 2010 Author Share Posted August 13, 2010 (edited) it is very close, and much simpler then mine, one bug i found was set the time to 01:56 AM and clikc the test, it goes to 02:30 AM, so its close. good work, im going to work with it. thanks okay i made a two changes that seem to fix it all (well, all of what i have tested, and i havn't found any more bugs, yet) all i did was make change the line if $min = 60 Then to if $min >= 60 Then and the line Return $hour & ":" & $min & " " to Return $hour & ":" & $min & $am_pm that seemed to fix everything. Edited August 13, 2010 by redLabel 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