Dave
14-04-2008, 20:58
Hi.
I'm having trouble with one or two of the date functions so I wonder if someone can point me in the right direction please? I'll use the following code to illustrate:
uses "ui", "dt"
dim hwnd, msg, wparam, lparam as dword
dim strTimeAdjust as string
dialog new 0, "Time test", - 1, - 1, 260, 90, %ws_sysmenu, 0 to hwnd
control add frame, hwnd, 1, "Adjust time", 5, 5, 125, 60
control add button, hwnd, 2, "Hours +", 15, 17, 50, 17
control add button, hwnd, 3, "Hours -", 15, 40, 50, 17
control add button, hwnd, 4, "Minutes +", 70, 17, 50, 17
control add button, hwnd, 5, "Minutes -", 70, 40, 50, 17
control add label, hwnd, 6, "Current time", 140, 18, 50, 12, %ss_center
control add label, hwnd, 7, Dt_Timeformat(,"hh.mm"), 205, 18, 40, 12, %ss_left
control add label, hwnd, 8, "Adjusted time", 140, 35, 50, 12, %ss_center
control add label, hwnd, 9, Dt_Timeformat(Dt_GetTime(),"hh.mm"), 205, 35, 40, 12, %ss_left
dialog show modeless hwnd
while iswindow( hwnd )
msg = getmessage( hwnd, wparam, lparam )
control set text hwnd, 7, Dt_Timeformat(,"hh.mm")
select case msg
case %wm_syscommand
if wparam = %sc_close then
exit while
end if
case %wm_command
select case wparam
case 2
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timeaddseconds( strTimeAdjust, %dt_seconds_in_hour )
case 3
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timesubseconds( strTimeAdjust, %dt_seconds_in_hour )
case 4
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timeaddseconds( strTimeAdjust, %dt_seconds_in_minute )
case 5
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timesubseconds( strTimeAdjust, %dt_seconds_in_minute )
end select
end select
wend
dialog end hwnd
1) control add label, hwnd, 7, Dt_Timeformat(,"hh.mm"), 205, 18, 40, 12, %ss_left
This still shows the seconds even though I have specified "hh.mm". I have tried "'hh'.'mm'" but I get the same result. BTW I am aware that this value gets updated later in the code but I get the same result.
2) control add label, hwnd, 9, Dt_Timeformat(Dt_GetTime(),"hh.mm"), 205, 35, 40, 12, %ss_left
This gives me the format I want but the wrong time. Instead of 17.00 I got 06.00.
3) The hours and minutes can be adjusted forward but not backwards after 00:00. The minutes work backwards after the hour except if the hour is 00:00. I am aware that this changes the formatting of the date, but I am just illustrating what is happening.
Sorry if I'm missing something obvious. Thanks.
I'm having trouble with one or two of the date functions so I wonder if someone can point me in the right direction please? I'll use the following code to illustrate:
uses "ui", "dt"
dim hwnd, msg, wparam, lparam as dword
dim strTimeAdjust as string
dialog new 0, "Time test", - 1, - 1, 260, 90, %ws_sysmenu, 0 to hwnd
control add frame, hwnd, 1, "Adjust time", 5, 5, 125, 60
control add button, hwnd, 2, "Hours +", 15, 17, 50, 17
control add button, hwnd, 3, "Hours -", 15, 40, 50, 17
control add button, hwnd, 4, "Minutes +", 70, 17, 50, 17
control add button, hwnd, 5, "Minutes -", 70, 40, 50, 17
control add label, hwnd, 6, "Current time", 140, 18, 50, 12, %ss_center
control add label, hwnd, 7, Dt_Timeformat(,"hh.mm"), 205, 18, 40, 12, %ss_left
control add label, hwnd, 8, "Adjusted time", 140, 35, 50, 12, %ss_center
control add label, hwnd, 9, Dt_Timeformat(Dt_GetTime(),"hh.mm"), 205, 35, 40, 12, %ss_left
dialog show modeless hwnd
while iswindow( hwnd )
msg = getmessage( hwnd, wparam, lparam )
control set text hwnd, 7, Dt_Timeformat(,"hh.mm")
select case msg
case %wm_syscommand
if wparam = %sc_close then
exit while
end if
case %wm_command
select case wparam
case 2
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timeaddseconds( strTimeAdjust, %dt_seconds_in_hour )
case 3
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timesubseconds( strTimeAdjust, %dt_seconds_in_hour )
case 4
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timeaddseconds( strTimeAdjust, %dt_seconds_in_minute )
case 5
control get text hwnd, 9 to strTimeAdjust
control set text hwnd, 9, dt_timesubseconds( strTimeAdjust, %dt_seconds_in_minute )
end select
end select
wend
dialog end hwnd
1) control add label, hwnd, 7, Dt_Timeformat(,"hh.mm"), 205, 18, 40, 12, %ss_left
This still shows the seconds even though I have specified "hh.mm". I have tried "'hh'.'mm'" but I get the same result. BTW I am aware that this value gets updated later in the code but I get the same result.
2) control add label, hwnd, 9, Dt_Timeformat(Dt_GetTime(),"hh.mm"), 205, 35, 40, 12, %ss_left
This gives me the format I want but the wrong time. Instead of 17.00 I got 06.00.
3) The hours and minutes can be adjusted forward but not backwards after 00:00. The minutes work backwards after the hour except if the hour is 00:00. I am aware that this changes the formatting of the date, but I am just illustrating what is happening.
Sorry if I'm missing something obvious. Thanks.