Extending the date range of the date gadget?
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Extending the date range of the date gadget?
I don't really want to hack my forms or my code after spending all this time designing them with the VISUAL designer (too damned tired most days) and as MSDN tells me that windows *should* be able to handle dates all the way down to 1603, I'd like to know if there is any way to extend the date range of PB's dategadget beyond the 1970 limit?
Many of the people I deal with have birthdays 30 to 40 years before (1970) that!!! And I was thinking of writing a simple genealogy database and once again I hit the date limit.
Regards all.
Many of the people I deal with have birthdays 30 to 40 years before (1970) that!!! And I was thinking of writing a simple genealogy database and once again I hit the date limit.
Regards all.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: Extending the date range of the date gadget?
Have a look at DateCount at my PureBasic Corner:
http://home.mnet-online.de/horst.muc/pb/
.. and check out my Date Reminder program in the Windows section...
http://home.mnet-online.de/horst.muc/pb/
.. and check out my Date Reminder program in the Windows section...
Horst.
The Problem here is not with the Gadget, but with PB's Date library.
The Date lib uses the unix timestamp format, which ranges only from 1970 to 2030.
If you use the Api to get and set the date, you can go back to 1753 if you want.
What you will have to deal with is the SYSTEMTIME structure. It is quite simple,
it has one field for each part of the date:
Now getting and setting the dates in the DateGadget is quite easy:
Just do not use the Date library for any of these dates, as this is what is limited to 1970.
The Date lib uses the unix timestamp format, which ranges only from 1970 to 2030.
If you use the Api to get and set the date, you can go back to 1753 if you want.
What you will have to deal with is the SYSTEMTIME structure. It is quite simple,
it has one field for each part of the date:
Code: Select all
Structure SYSTEMTIME
wYear.w
wMonth.w
wDayOfWeek.w
wDay.w
wHour.w
wMinute.w
wSecond.w
wMilliseconds.w
EndStructure
Code: Select all
#DTM_GETSYSTEMTIME = $1001
#DTM_SETSYSTEMTIME = $1002
#GDT_VALID = 0
; Get Date:
;
SendMessage_(GadgetID(#YourGadget), #DTM_GETSYSTEMTIME, 0, @CurrentDate.SYSTEMTIME)
; Set Date:
;
SendMessage_(GadgetID(#YourGadget), #DTM_SETSYSTEMTIME, #GDT_VALID, @NewDate.SYSTEMTIME)
quidquid Latine dictum sit altum videtur
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Thanks but...
Fred was kind enough to email me back with an explanation of the problem which I accept and Horst pointed me to his code to look at with those very structures in it. I've fixed up the code thanks to him and released a fixed version of Portable SQLite address book.
It's hard to live brainless like me

It's hard to live brainless like me



Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Fred explained to me that it isn't a simple library fix, it's a 'fix' that would require work at the heart of the compiler, major rework. (This is how I remember the email, I could be wrong)
And to be honest, I agree with him that for how few of us need dates to go that far back, it is certainly not worth the effort that it would take to just please us.
With Freak's examples and Horst's code, I turned them into re-useable routines and solved my problem.
And; if you own purevision designer; it has the facility to visually include an API date gadget with extended range so you have loads of choices.
If you ask Gnozal; the hardest working code out-putterer I know, he might add one in for you as well.
You could ask Bericko to include one in the official visual designer as well.
Byo, there is nothing stopping you from converting your code at all.
And to be honest, I agree with him that for how few of us need dates to go that far back, it is certainly not worth the effort that it would take to just please us.
With Freak's examples and Horst's code, I turned them into re-useable routines and solved my problem.
And; if you own purevision designer; it has the facility to visually include an API date gadget with extended range so you have loads of choices.
If you ask Gnozal; the hardest working code out-putterer I know, he might add one in for you as well.
You could ask Bericko to include one in the official visual designer as well.
Byo, there is nothing stopping you from converting your code at all.
I see. Thank you for your advices.
Maybe I should search a little more for a solution.
I just thought that the DateGadget and the inner date functions could someday be synchonized without a lot of work. But I can live without it if ther are so many workarounds. Thanks for letting me know where to look.
Maybe I should search a little more for a solution.
I just thought that the DateGadget and the inner date functions could someday be synchonized without a lot of work. But I can live without it if ther are so many workarounds. Thanks for letting me know where to look.
Proud registered Purebasic user.
Because programming should be fun.
Because programming should be fun.
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
You may have to ask Freak that. I have the funny feeling that the maximum date range of the library may be based on maximum ms date range.
/me wonders how far system bios goes too...
P.s. My home inventory and address book programs use dates based on Freak's example and Horst's code and they work great.
I have also asked the author of purevision if he could put the old api date back in but he seems to be busy these days and I don't know if he has the time.
If you use Gnozal's visual designer, ask him to put one in as his designer is quite extendible. Then you would not have to hack forms after design.
/me wonders how far system bios goes too...
P.s. My home inventory and address book programs use dates based on Freak's example and Horst's code and they work great.
I have also asked the author of purevision if he could put the old api date back in but he seems to be busy these days and I don't know if he has the time.
If you use Gnozal's visual designer, ask him to put one in as his designer is quite extendible. Then you would not have to hack forms after design.
But that was before the quad engine. If the date was stored in a quad instead of a long it would "only" be a library rewrite, not a change in the compiler.Fangbeast wrote:Fred explained to me that it isn't a simple library fix, it's a 'fix' that would require work at the heart of the compiler, major rework. (This is how I remember the email, I could be wrong)
Alternatively, the library could use numbered "date objects" (like gadgets) instead of passing the actual dates around. That would slow everything down, but it would be possible without a change to the compiler, and could allow for any date range.
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
I wouldn't know, I never asked him since I have a working solution and am no longer interested in having it changed.
If the code works well, I see no need to change pb to suit me.
Unless some kind soul want to write a visual designer that supports all pb gadgets with all possible options. Then I would change all my working code (at major risk) to use this designer.
MrMatt, hurry up with woken will you???? (Pant, dribble, drool, lust)
If the code works well, I see no need to change pb to suit me.
Unless some kind soul want to write a visual designer that supports all pb gadgets with all possible options. Then I would change all my working code (at major risk) to use this designer.
MrMatt, hurry up with woken will you???? (Pant, dribble, drool, lust)
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Thanks but...
Do you mean there's a valid reason why 1970-2038 are the only years available? What did Fred say?Fangbeast wrote:Fred was kind enough to email me back with an explanation of the problem which I accept
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Thanks but...
If you sum up every second from 1970 on, a LONG variable will be filled in 2038.MachineCode wrote:Do you mean there's a valid reason why 1970-2038 are the only years available? What did Fred say?Fangbeast wrote:Fred was kind enough to email me back with an explanation of the problem which I accept
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!