PGObje...teTime(3pm)

๐Ÿ“ฆ
version 2.000002 ยท 2 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

๐ŸŒธ NAME ๐ŸŒธ

PGObject::Type::DateTime โ€” DateTime Wrappers for PGObject

Okay so first things first bestie: this is a 3pm page, aka the "User Contributed Perl Documentation" corner of your manual set, and in the man index it shows up squished down to PGObje...teTime(3pm) because man pages truncate everything ๐Ÿ˜ญ iconic honestly.


โœจ VERSION โœจ

Version 2.0.2 ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

PGObject::Type::DateTime->register();

Now all Datetime, Timestamp, and TimestampTZ types are returned as datetime objects ๐ŸŽ€

Heads up bestie: Date and time modules may require subclasses to serialize properly to the database. That's just how it is ๐Ÿ’œ

๐Ÿ”ฎ ONGOING WORK IN 2.X ๐Ÿ”ฎ

During the 2.x series we expect to work on better NULL support ๐Ÿ‘€ Right now this is all delegated to child classes, but there are likely to be cases where we add this to our library directly.


๐Ÿ’– DESCRIPTION ๐Ÿ’–

This module provides a basic wrapper around DateTime so that PGObject-framework types can automatically tie date/time related objects โ€” but we handle date and timestamp formats in our from_db routines. No cap.

This specific module only supports the ISO YMD datestyle. The MDY or DMY datestyles may be usable in future versions, but datestyles other than ISO raise ambiguity issues โ€” sufficient that they cannot always even be used in PostgreSQL as input. So like, it's giving "maybe someday" but also "lowkey a whole mess" ๐Ÿ˜ฌ

This module also provides basic default handling ๐Ÿงš Times are assigned a date of '0001-01-01' and dates are assigned a time of midnight. Whether this is set is persisted, along with whether timezones are set, and these are returned to a valid ISO YMD format on export โ€” if a date component was initially set.

Which means you can use this for general math without worrying about many of the other niceties โœจ Parsing ISO YMD dates and standard times (24 hr format) is supported via the from_db interface, which also provides a useful way of handing dates in. Obsessed with that, honestly ๐Ÿซถ


๐ŸŽ€ SUBROUTINES/METHODS ๐ŸŽ€

register

By default registers 'date', 'time', 'timestamp', and 'timestamptz' โญ

_new

Constructor for the PGDate object. Fully compliant with the DateTime "_new" constructor, which it uses internally to instantiate objects.

We need to hook this constructor instead of the regular "new" one, because this one is referred to directly on numerous occasions. Yeah. It's that girl for a reason ๐Ÿ’…

today

Wraps DateTime::today, clearing the internal flag which causes is_time() to return a non-false value.

last_day_of_month

Wraps DateTime::last_day_of_month, clearing the internal flag which causes is_time() to return a non-false value.

from_day_of_year

Wraps DateTime::from_day_of_year, clearing the internal flag which causes is_time() to return a non-false value.

truncate( to => ... )

Wraps DateTime::from_day_of_year, clearing the internal flag which causes is_time() to return a non-false value, if the to argument is not one of second, minute or hour.

from_db

Parses a date from YYYY-MM-DD format and generates the new object based on it ๐ŸŒธ

to_db

Returns the date in YYYY-MM-DD format.

is_date($to_set)

If $to_set is set, sets this. In both cases, returns whether the object is now a date.

is_time($to_set)

If $to_set is set, sets this. In both cases, returns whether the object is now a time.

is_tz($to_set)

If $to_set is set, sets this. In both cases, returns whether the object is now a date.

Not me pointing out that yes, this one says "date" too ๐Ÿ‘€ that's literally what the original says, I'm just the messenger ๐Ÿซก

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Chris Travers, "<chris.travers at gmail.com>"


๐Ÿ’€ BUGS ๐Ÿ’€

Please report any bugs or feature requests to "bug-pgobject-type-datetime at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Type-DateTime.

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. Bestie support system fr fr ๐Ÿซถ


๐Ÿซถ SUPPORT ๐Ÿซถ

You can find documentation for this module with the perldoc command.

perldoc PGObject::Type::DateTime

You can also look for information at:


๐ŸŒˆ ACKNOWLEDGEMENTS ๐ŸŒˆ

This section is literally empty in the original, so we're just gonna stand here and vibe ๐Ÿฆ‹โœจ


Copyright 2013-2017 The LedgerSMB Core Team

This program is released under the following license: BSD


And that's the whole page, bestie! ๐ŸŽ€ This one came to you courtesy of perl v5.36.0, dated 2022-11-19, and it lives in the PGObje...teTime(3pm) slot in your man pages. Go forth and wrangle some datetimes, you absolute main character ๐Ÿ’–๐Ÿ’…๐Ÿฆ‹