I also don't know if this shows up in other countries.
When using the Calendar or Date gadget the date returned gets screwed up and becomes different at certain times of the day.
The time component seems to lock onto the time the gadget launches and is different depending on how it's accessed.
The date gets out of step possibly due to mismanagement of time zones.
I have built a small app to demonstrate the issue but if the time zone problem doesn't show up for you it won't mean anything.
Also you'll have to test it over the course of a day to see what happens.
I have built into the app the work around that I use because that seems to be consistently accurate here in Australia.
The screenshots in the link show the discrepancy in the dates reported by the Calendar and Date gadgets. The local time I collected these screenshots was 3:31 pm.
https://www.evernote.com/shard/s382/sh/ ... 138c920827
You can see that the time for GetGadgetText is wrong and the date for GetGadgetState is wrong.
For your testing the code I used is below. If I've screwed up somewhere please let me know, but I want this functionality to be cross platform.
DateTest.pbf:
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global Window_2
Global Text_0, CalDate, Date_0
Enumeration FormFont
#Font_Window_2_0
EndEnumeration
LoadFont(#Font_Window_2_0,"Founders Grotesk Text", 23, #PB_Font_Bold)
Procedure OpenWindow_2(x = 0, y = 0, width = 600, height = 400)
Window_2 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
Text_0 = TextGadget(#PB_Any, 0, 10, 600, 40, "Date test page.", #PB_Text_Center)
SetGadgetFont(Text_0, FontID(#Font_Window_2_0))
CalDate = CalendarGadget(#PB_Any, 180, 70, 230, 200, 0)
Date_0 = DateGadget(#PB_Any, 170, 290, 240, 40, "")
EndProcedure
Procedure Window_2_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
ProcedureReturn #True
EndProcedureCode: Select all
Declare.s PickM(name$)
XIncludeFile "DateTest.pbf"
OpenWindow_2()
Procedure WeekOfMonth(targetDate)
If Mod(targetDate,7) = 0
WeekNum.i = targetDate / 7
Else
WeekNum.i = (targetDate / 7) + 1
EndIf
ProcedureReturn WeekNum
EndProcedure
Procedure.s PickM(name$)
Select name$
Case "January"
Month$ = "1"
ProcedureReturn Month$
Case "February"
Month$ = "2"
ProcedureReturn Month$
Case "March"
Month$ = "3"
ProcedureReturn Month$
Case "April"
Month$ = "4"
ProcedureReturn Month$
Case "May"
Month$ = "5"
ProcedureReturn Month$
Case "June"
Month$ = "6"
ProcedureReturn Month$
Case "July"
Month$ = "7"
ProcedureReturn Month$
Case "August"
Month$ = "8"
ProcedureReturn Month$
Case "September"
Month$ = "9"
ProcedureReturn Month$
Case "October"
Month$ = "10"
ProcedureReturn Month$
Case "November"
Month$ = "11"
ProcedureReturn Month$
Case "December"
Month$ = "12"
ProcedureReturn Month$
EndSelect
EndProcedure
; The main event loop as usual
Repeat
event = WaitWindowEvent() ; 250)
window = EventWindow()
Select event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case CalDate
Cal = GetGadgetState(CalDate)
Debug Cal
Cal$ = FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", Cal)
Text$ = GetGadgetText(CalDate)
Debug "GadgetText: " + Text$ + Chr(10) + "GadgetState: " + Cal$
Debug "Day " + Str(Day(cal))
Debug "Month " + Str(Month(cal))
Debug "Today Month " + Str(Month(Date()))
Debug "Today DoW " + Str(DayOfWeek(cal))
Debug "Today WoM " + Str(WeekOfMonth(Day(cal)))
;Saturday, 22 October 2022 at 3:18:11
Day$ = Mid(Text$,FindString(Text$, ", ") + 2, 2)
Year$ = Mid(Text$,FindString(Text$, " 202") + 1,4)
Month$ = Mid(Text$,FindString(Text$, Day$) + 2,FindString(Text$, Year$) - FindString(Text$, Day$)-2)
Month$ = PickM(Trim(Month$))
Debug Day$ + ", " + Month$ + ", " + Year$ + " from GadgetText string"
;Dates$ =
Cal2 = ParseDate("%dd/%mm/%yyyy",Day$ + "/" + Month$ + "/" + Year$)
Debug Str(Cal2) + " -- " + Str(Day(Cal2)) + "/" + Str(Month(Cal2)) + Chr(10)
Case target
Debug "Target"
EndSelect
EndSelect
ForEver// Added Code-Tags (Kiffi)


