DateEx: Extended Date library

Share your advanced PureBasic knowledge/code with the community.
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

victorprogra wrote: Fri Dec 29, 2023 7:05 pm Runs Perfect! on macOS (intel)
I'm glad to read that. :-) You are welcome!
Thank you for your kind and detailed feedback!
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.00, 2024-01-14

Fixed
  • Bug in Procedure DateDiff()
Changed
  • improved error handling
  • cosmetic changes
  • extended and improved comments
New
  • Many procedures now have the additional optional parameter 'calendar', so that they can use the Julian calendar even for dates after 1582-10-04.
  • Procedure Easter() now can also calculate dates for the Julian calendar.
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

With version 2.0 of the module, you can now easily convert dates from the Julian calendar to the Gregorian calender and vive versa.
For instance, the Orthodox Catholic Church celebrates Christmas on Dezember 25th, according to the Julian calendar.
What is the corresponding date in the Gregorian calendar?
The answer depends on the year in question, because the gap between the Julian and Gregorian calendars increases over time:

Code: Select all

XIncludeFile "DateEx.pbi"
UseModule DateEx

#Mask$ = "%yyyy-%mm-%dd"
Define.q date

date = DateQ(1582, 12, 25, 0, 0, 0, #Julian)
Debug FormatDateQ(#Mask$, date, #Gregorian)    ; 10 days later

date = DateQ(2023, 12, 25, 0, 0, 0, #Julian)
Debug FormatDateQ(#Mask$, date, #Gregorian)    ; 13 days later
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.01, 2024-03-03

Changed
  • Fixed bugs
  • Renamed procedure TimeZoneOffset() to TimeZone()
  • New public procedure TimeZoneStr()
  • New public procedure BlackFriday()
ebs
Enthusiast
Enthusiast
Posts: 556
Joined: Fri Apr 25, 2003 11:08 pm

Re: DateEx: Extended Date library

Post by ebs »

I know it's dumb to ask "Why do I get this error?" when using an ancient version of PureBasic (5.43 LTS), but I'm stuck here for business reasons.

My problem is this Linker error I get when compiling DateEx on Windows 11:

POLINK: error: Unresolved external symbol '_Time'.
POLINK: fatal error: 1 unresolved external(s)


I believe the cause is this import statement:

Code: Select all

   ImportC ""
      Time(*tm=#Null)
      localtime(*t.Quad)
   EndImport

Can anyone tell me how to fix this? Thanks!
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

I tested the current version 2.01 of my module with PureBasic 5.43 LTS (both 32 bit and 64 bit) on Windows 11 Pro.
But I can't reproduce the problem.
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.02, 2024-10-30

Changed
  • Small internal improvement
  • Some comments slightly improved
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: DateEx: Extended Date library

Post by dige »

Thx Little John. I wanted to give it a quick try. But Assert () is not a function?
"Daddy, I'll run faster, then it is not so far..."
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

Hi dige, thanks for your interest.
Assert() comes with PureBasic, but it's hidden. For the Assert() macro to work, the file "PureUnit.res" in PureBasic's "Sdk\PureUnit" subdirectory must be moved to the "Residents" subdirectory.
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.03, 2024-11-25

Changed
  • Small internal improvements
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.04, 2025-02-08

Fixed
  • Bug in Procedure ParseDateQ()
User avatar
Piero
Addict
Addict
Posts: 863
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: DateEx: Extended Date library

Post by Piero »

Little John wrote: Sat Feb 08, 2025 2:32 pmParseDateQ()
Works well on Mac (after copying PureUnit.res) Thanks!

PS: I just finished to edit this delirium if you may be interested :)
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

New version 2.05, 2025-06-30

New
  • Procedure DateFromDayOfYear (year.i, dayNo.i, calendar.i=#Default)
This version was successfully tested also with PB 6.21 (x64) on
[v] Windows 11
[v] Linux Mint 22.1
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: DateEx: Extended Date library

Post by Quin »

Very nice. Thanks!
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DateEx: Extended Date library

Post by Little John »

Thank you, Quin. You are welcome!
Post Reply