Having a cross platform standard date range defined by an operating system limitation (i.e. Windows) is compromised, shortsighted rationale IMHO. If you consider the subject of genealogy and family history, the recording of historical dates easily go earlier than 1601. Certainly linked historical records precede 1601 as well. It would be very valuable and practical if a generic date/calendar capability could be established that is agnostic of operating system. I understand there is a solution to this already with the Julian Day number system used as the underpinning for calendrical computations (not to be confused to Julian Date which is something different).freak wrote: Tue Dec 26, 2023 12:28 amThe range is a Windows API limitation. It comes from limits in the SYSTEMTIME and FILETIME structures (see here: https://learn.microsoft.com/en-us/windo ... systemtime)Andre wrote: Mon Dec 25, 2023 11:22 pmI hadn't the time to test PB 6.10 yet, but what I don't understand is the purpose of the new date range.... I would have expected that a greater supported range of around 29,000 years will go from history (let's say 20,000 BC) till future (e.g. year 9,000) to be usable for such purposes. Or do I see the goal of this new range not...Sicro wrote: Mon Dec 25, 2023 12:47 pm...PureBasic 6.10 beta 1 - Xmas Release - is out ! wrote:Updated: Date library for full 64bit support (new range is year 1601 to 30827)![]()
We apply the same limit to the other OS to have a portable library with common limits.
It should be enough for all practical purposes. Dates like 20000BC make no sense to represent this way since the calendar we use did not exist then and it makes no sense to represent date and time that far back with a precision of seconds.
Update FormatDate() and ParseDate() to the new date range
-
- User
- Posts: 29
- Joined: Thu Aug 03, 2023 5:44 pm
- Location: Off Planet
Re: Update FormatDate() and ParseDate() to the new date range
Re: Update FormatDate() and ParseDate() to the new date range
Keep in mind that there are also other libraries which should fit your genealogy problem.
I guess the internal function is made for file dates primarily, which it fits.
I guess the internal function is made for file dates primarily, which it fits.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Update FormatDate() and ParseDate() to the new date range
It's not short sighted, it's on purpose. The idea behind this is to have the PureBasic programs behave the same accross all supported OS, so we need to take in account for the OS limitations. As you said, if you need to have larger range for specific programs (genealogy etc) you can still have a third party module like this one: https://www.purebasic.fr/english/viewto ... t=calendar
-
- User
- Posts: 29
- Joined: Thu Aug 03, 2023 5:44 pm
- Location: Off Planet
Re: Update FormatDate() and ParseDate() to the new date range
I'm just expressing an opinion, feedback to consider. I certainly understand the deliberate rationale of striving to have the same "thing" across all supported OS ... indeed, the design intent of OS abstraction is what I love about PureBasic. Yes, it is necessary to work out what is practical to take into account OS limitations. I understand that perspective. But ...Fred wrote: Thu Dec 28, 2023 11:10 am It's not short sighted, it's on purpose. The idea behind this is to have the PureBasic programs behave the same accross all supported OS, so we need to take in account for the OS limitations. As you said, if you need to have larger range for specific programs (genealogy etc) you can still have a third party module like this one: https://www.purebasic.fr/english/viewto ... t=calendar
Isn't it worth considering going further, where practical and feasible to do so, to consider introducing capability not constrained by OS limitations where there is a proven approach to do so? Third party libraries exist because they extend what is lacking in the core. In the case of calendars, having a core capability constrained to start at 1601 just looks quite odd. So perhaps my original critique is better directed at the Windows designers!
Thank you for pointing out the third party module. That is useful. For anyone interested in disappearing down the rabbit whole of calendars and their calculations, I can recommend the following:
Names: Reingold, Edward M., 1945– author. | Dershowitz, Nachum, author. Title: Calendrical calculations : the ultimate edition / Edward M. Reingold,
Illinois Institute of Technology, Chicago, Nachum Dershowitz, Tel Aviv University, Israel. Description: Fourth edition. | Cambridge : Cambridge University Press, 2017.
Identifiers: LCCN 2017024295| ISBN 9781107057623 (hardback)
Re: Update FormatDate() and ParseDate() to the new date range
After thinking about this topic a bit more I have decided to revert this change and instead restrict the allowed year range for the library to year 9999 max to solve this issue. Year values up to 30827 really have no practical use and so complicating things for everybody just to make a theoretical case possible is not a good idea.freak wrote: Wed Dec 27, 2023 12:54 am Introduced a new "%yyyyy" format token to handle 5 digit years. If used on a 4 digit year it will force a leading 0 in FormatDate() to ensure proper parsing in ParseDate().
The "%yyyy" format token is restricted to 4 digits output even if the year has 5 digits.
The purpose of this library is to be easy to use and consistent for the most common use cases. The previous range of 1970-2038 became too limited for this mostly due to the 2038 problem and not even primarily due to the 1970 limit. Having a now extended range of 1601-9999 is a great improvement over this and should fit almost every PB program just fine.
The arguments of trying to justify extreme ranges seem a bit made up to me. I have not seen many genealogy or archeology apps in PB yet and I do not think it is likely that PB will become popular in the nuclear waste management sector requiring year values in the +30000 range either. IF somebody were to write such a specialty app then THEY should bear the burden of the added complexity, not the average PB user who just wants a simple working date picker in their program.
It was considered and we decided it not to be feasible in this case. The date library has many points of interaction with OS components (CalendarGadget, DateGadget, File dates etc) which have to work reliably and consistently as well across all platforms. It is NOT just about parsing and printing dates. If these things don't work properly together then people would (rightfully) see that as a bug.DayDreamer wrote: Thu Dec 28, 2023 1:42 pm Isn't it worth considering going further, where practical and feasible to do so, to consider introducing capability not constrained by OS limitations where there is a proven approach to do so?
I have spend a lot more time on this Date library redesign that I would ever have imaged would be needed. There is a lot more complexity involved than you would think. Trust me: The limits we have now ARE the limits of what is practical and feasible.
Btw: The limits are just an implementation detail. It is always possible to extend them in the future in a backward compatible way if that becomes needed. Nothing is set in stone here.
quidquid Latine dictum sit altum videtur
Re: Update FormatDate() and ParseDate() to the new date range
That's why I have created this feature request that %yyyy should be changed so that it doesn't read the first 4 digits, but the last 4 digits. And there should be a new token %yyyyy (5 times "y") that can handle years with 5 digits.
How %yyyy currently works does not contradict how it is documented, because it was not written that it is the last 4 digits of the year. But yes, normally you would expect this, so it can be seen as a bug, even if it doesn't contradict the documentation. All good

That's ok for me.freak wrote: Wed Dec 27, 2023 12:54 am Introduced a new "%yyyyy" format token to handle 5 digit years. If used on a 4 digit year it will force a leading 0 in FormatDate() to ensure proper parsing in ParseDate().
The "%yyyy" format token is restricted to 4 digits output even if the year has 5 digits.
That's how I see it too. Yes, specialized includes/modules/libraries should be used for much larger date ranges.jacdelad wrote: Thu Dec 28, 2023 11:06 am Keep in mind that there are also other libraries which should fit your genealogy problem.
I guess the internal function is made for file dates primarily, which it fits.
@Andre @DayDreamer
Of course, it would be nice if the native date library itself supported this, but it doesn't need to. But then it should be a separate calendar library, because the date ranges are then no longer compatible with the OS components (such as DateGadget()).

Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Update FormatDate() and ParseDate() to the new date range
Yes, it's better.freak wrote: Thu Dec 28, 2023 2:51 pm After thinking about this topic a bit more I have decided to revert this change and instead restrict the allowed year range for the library to year 9999 max to solve this issue. Year values up to 30827 really have no practical use and so complicating things for everybody just to make a theoretical case possible is not a good idea.

Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Update FormatDate() and ParseDate() to the new date range
Re: Update FormatDate() and ParseDate() to the new date range
Ok, then you saw the lack of support for the new date range in the commands mentioned as a bug. Yes, it can be seen that way. I also wondered at first whether I should post it as a bug or a feature request. All good.Little John wrote: Thu Dec 28, 2023 5:00 pm... and I never wrote that. I wrote this.Sicro wrote: Thu Dec 28, 2023 3:51 pm How %yyyy currently works does not contradict how it is documented

Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: [BUG]Re: Update FormatDate() and ParseDate() to the new date range
How about introducing a new function named say LastError() into PureBasic?freak wrote: Mon Dec 25, 2023 4:06 pmThat is on purpose. The value -1 has always meant "invalid date" in the PB date library so we have to keep that for backward compatibility. Changing that would break a lot of code so having this one specific second be non-representable is the lesser of two evils here.juergenkulow wrote: Mon Dec 25, 2023 3:03 pmCode: Select all
; The last second of the year 1969 does not exist for FormatDate.
When that function does not indicate an error, then -1 is a valid date value.
In the documentation of LastError(), it can be written that the function currently only supports the Date library. If needed, support for other libraries can be added step by step with new PB releases. Just an idea.
Re: Update FormatDate() and ParseDate() to the new date range
How would this proposed function work when working with threads?
Last edited by jacdelad on Fri Dec 29, 2023 3:56 pm, edited 1 time in total.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Update FormatDate() and ParseDate() to the new date range
With compiler option thread safe
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Update FormatDate() and ParseDate() to the new date range
Ah ok. Makes sense.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD