Hi Dave.
I've moved this post into DT specific module.
I confirm there are some problems. Roberto will have a look asap.
Eros
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:
[code=thinbasic]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[/code]
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.
Hi Dave.
I've moved this post into DT specific module.
I confirm there are some problems. Roberto will have a look asap.
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thank you Eros.
Hi Dave,
I changed both DT_GetTime() and DT_FormatTime() adding a flag that change the behaviour of these function.
Here is a summary for the new flags use:
%DT_GETLOCALTIME Used by DT_GetTime() Retrieves the current local date and time.This is the dafault value
%DT_GETSYSTEMTIME Used by DT_GetTime() Retrieves the current system date and time.The system time is expressed in Coordinated Universal Time (UTC).
%DT_NOMINUTESORSECONDS Used by DT_FormatTime() Do not use minutes or seconds.
%DT_NOSECONDS Used by DT_FormatTime() Do not use seconds.
%DT_NOTIMEMARKER Used by DT_FormatTime() Do not use a time marker.
%DT_FORCE24HOURFORMAT Used by DT_FormatTime() Always use a 24-hour time format.
Also changed the DT_MILLISECTOTIME() and DT_TIMETOMILLISEC() functions in order to fix a bug with milliseconds discovered by Eros.
As usual you'll find these update in the next ThinBasic release.
[code=thinbasic]uses "dt"
msgbox 0, DT_MILLISECTOTIME(DT_TIMETOMILLISEC("08:12:24.003"))
msgbox 0, "Local Time:" + $TAB + DT_GetTime(%DT_GETLOCALTIME) + $CRLF + "System Time:" + $TAB + DT_GetTime(%DT_GETSYSTEMTIME)
msgbox 0, "Default to local time:" + $TAB + DT_GetTime()
msgbox 0, Dt_Timeformat(,"hh.mm", %DT_NOSECONDS)
[/code]
Regards,
Roberto
http://www.thinbasic.com
Hi Dave.
Roberto sent me an updated version of DT module.
Please find here attached thinBasic_DT.dll
Copy it into \thinBasic\Lib\ directory replacing your current one.
Also here a modified version of your script using new functionalities and fixes.
Ciao
Eros
[code=thinbasic]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", %DT_FORCE24HOURFORMAT), 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", %DT_FORCE24HOURFORMAT), 205, 35, 40, 12, %ss_left
dialog show modeless hwnd
while iswindow( hwnd )
msg = getmessage( hwnd, wparam, lparam )
control_settext(hwnd, 7, Dt_Timeformat( ,"hh.mm", %DT_FORCE24HOURFORMAT))
select case msg
case %wm_syscommand
if wparam = %sc_close then
exit while
end if
case %wm_command
select case wparam
case 2
strTimeAdjust = dt_timeaddseconds( control_GetText(hwnd, 9), %dt_seconds_in_hour )
control_setText(hwnd, 9, Dt_Timeformat(strTimeAdjust,"hh.mm", %DT_FORCE24HOURFORMAT))
case 3
strTimeAdjust = dt_timesubseconds( control_GetText(hwnd, 9), %dt_seconds_in_hour )
control_setText(hwnd, 9, Dt_Timeformat(strTimeAdjust,"hh.mm", %DT_FORCE24HOURFORMAT))
case 4
strTimeAdjust = dt_timeaddseconds( control_GetText(hwnd, 9), %dt_seconds_in_minute )
control_setText(hwnd, 9, Dt_Timeformat(strTimeAdjust,"hh.mm", %DT_FORCE24HOURFORMAT))
case 5
strTimeAdjust = dt_timesubseconds( control_GetText(hwnd, 9), %dt_seconds_in_minute )
control_setText(hwnd, 9, Dt_Timeformat(strTimeAdjust,"hh.mm", %DT_FORCE24HOURFORMAT))
end select
end select
wend
dialog end hwnd
[/code]
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
A note:
to force 24 hours format you can do in the following either ways:
[code=thinbasic]Dt_Timeformat(strTimeAdjust,"hh.mm", %DT_FORCE24HOURFORMAT)[/code]
[code=thinbasic]Dt_Timeformat(strTimeAdjust,"HH.mm") '---HH capital[/code]
Regards
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi Eros,
idea with UCASE used to force 24 hourse is nice
Thanks guys,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Hi Eros / Roberto.
I'm surprised and impressed with how fast you've been able to make these changes. I really didn't expect it to be done so soon.
Thank you both very much.
Thanks.
That's our way of doing things.
Sometimes we are able sometimes not. But as we always say: we try our best for everyone using thinBasic.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thanks .
http://www.thinbasic.com
Bookmarks