This is a bit off topic, but Raku, the sister language of Perl, has a built-in Date object that should be able to handle the situation. I wonder if there is a possibility of someday having an interface with Raku as with Perl.
Note Raku has an excellent module to use PostgreSQL.
Blessings.
-Tom