date type? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: date type? (/showthread.php?tid=1514) |
RE: date type? - bplus - 03-01-2023 (03-01-2023, 09:58 AM)SMcNeill Wrote: You can get an UNIX timestamp from my posts here: https://staging.qb64phoenix.com/showthread.php?tid=65 +1 I agree! The main work has been done by converting any date + time into a number to which minutes, hours, days, weeks added or subtracted. Years might be tricky with leap years... RE: date type? - mnrvovrfc - 03-01-2023 (03-01-2023, 02:40 PM)Balderdash Wrote: SYSTEMTIME (minwinbase.h) - Win32 apps | Microsoft Learn Clever use of "printf()" in this one! Although I would define like 20 more examples for combinations like string, string, integer... makes me think of trig class: angle-angle-side congruent to angle-angle-side ROFL. More useful, though, would be "sprintf()" which puts the formatted text into a string. I looked into one of the JavaScript examples on Github but it could get seriously complicated, and it boils down to the use of the "built-in" Date function. That function is probably overriden. Otherwise the function to count milliseconds is implemented, while the one that counts seconds depends on that, then the one that counts minutes relies on the one that counts seconds, and so on. Actually I didn't look into source code of many of the functions. RE: date type? - SpriggsySpriggs - 03-01-2023 (03-01-2023, 04:16 PM)mnrvovrfc Wrote:@mnrvovrfc(03-01-2023, 02:40 PM)Balderdash Wrote: SYSTEMTIME (minwinbase.h) - Win32 apps | Microsoft Learn I've used printf a lot in QB64. It works great. sprintf also works well. Even the wide-string versions work well. RE: date type? - madscijr - 03-01-2023 (03-01-2023, 09:58 AM)SMcNeill Wrote: You can get an UNIX timestamp from my posts here: https://staging.qb64phoenix.com/showthread.php?tid=65 I love how simple that is, and can be used for so many other things. One question - I see it used 64-bit integers, this means it would be immune to the problem of UNIX dates not working past the year 2038? RE: date type? - Kernelpanic - 03-01-2023 Quote:Years might be tricky with leap years... The determination of leap years could be inserted. Code: (Select All) 'Bestimmung von Schaltjahren - 1. Maerz 2023 RE: date type? - TerryRitchie - 03-01-2023 (03-01-2023, 06:31 PM)Kernelpanic Wrote:Quote:Years might be tricky with leap years... Yes, as I recall many of the date functions run on a 400 and 100 year cycle such as leap years and the Easter calculation. RE: date type? - madscijr - 03-01-2023 (03-01-2023, 06:55 PM)TerryRitchie Wrote:(03-01-2023, 06:31 PM)Kernelpanic Wrote:Quote:Years might be tricky with leap years... I think if the tricky stuff like this can be identified then the logic can be added to handle it. Heck, if we simply hardcode the leap years upto the next 200 years then we're good to go right? LoL (Although we probably need to put in the info for past years as well, but it's doable.) Just saying... RE: date type? - mnrvovrfc - 03-01-2023 (03-01-2023, 05:29 PM)madscijr Wrote: One question - I see it used 64-bit integers, this means it would be immune to the problem of UNIX dates not working past the year 2038? Might have to take away from this result, but I got 2924712086.77536 years! Code: (Select All) $CONSOLE:ONLY EDIT: maybe this program is not accurate, but we are future-proof for our generation and for the generation just becoming adults now. At least on 64-bit MacOS, Linux and "what"BSD there should be no such limit. I don't know the technical workings of "btrfs", "ext4", "zfs" and other such file systems but they use 64-bit addressing for "inodes" and stuff like that. EDIT #2: It shouldn't be a problem with 64-bit representation of time then: https://en.wikipedia.org/wiki/Unix_time#Range_of_representable_times https://en.wikipedia.org/wiki/Year_2038_problem RE: date type? - SMcNeill - 03-02-2023 Don't you have everything you need here? https://staging.qb64phoenix.com/showthread.php?tid=690&pid=4565#pid4565 RE: date type? - bplus - 03-02-2023 (03-02-2023, 02:23 AM)SMcNeill Wrote: Don't you have everything you need here? https://staging.qb64phoenix.com/showthread.php?tid=690&pid=4565#pid4565 Ha I was going to post that LeapYear code but I see that and the kitchen sink in there! |