PGObject::Type::DateTime - DateTime Wrappers for PGObject
Version 2.1.1
PGObject::Type::DateTime->register();
Now all Datetime, Timestamp, and TimestampTZ types are returned returned as datetime objects. Date and time modules may require subclasses to serialize properly to the database.
During the 2.x series we expect to work on better NULL support. Right now this is all delegated to clild classes, but there are likely to be cases where we add this to our library directly.
This module provides a basic wrapper around DateTime to allow PGObject-framework types to automatically tie date/time related objects, but we handle date and timestamp formats in our from_db routines.
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.
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.
This means you can use this for general math without worrying about many of the other nicities. 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.
By default registers 'date', 'time', 'timestamp', and 'timestamptz'
Constructor for the PGDate object. Fully compliant with DateTime _new constructor which it uses internally to instantiate objects.
_new
We need to hook this constructor instead of the regular new one, because this one is referred to directly on numerous occasions.
new
Wraps DateTime::today, clearing the internal flag which causes is_time() to return a non-false value.
DateTime::today
is_time()
Returns a timestamp infinitely far in the future. This wraps DateTime::Infinite::Future.
DateTime::Infinite::Future
Returns a timestamp infinitely far in the past. This wraps DateTime::Infinite::Past
DateTime::Infinite::Past
Wraps DateTime::last_day_of_month, clearing the internal flag which causes is_time() to return a non-false value.
DateTime::last_day_of_month
Wraps DateTime::from_day_of_year, clearing the internal flag which causes is_time() to return a non-false value.
DateTime::from_day_of_year
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.
to
second
minute
hour
Parses a date from YYYY-MM-DD format and generates the new object based on it.
Returns the date in YYYY-MM-DD format.
If $to_set is set, sets this. In both cases, returns whether the object is now a date.
If $to_set is set, sets this. In both cases, returns whether the object is now a time.
Chris Travers, <chris.travers at gmail.com>
<chris.travers at gmail.com>
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.
bug-pgobject-type-datetime at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc PGObject::Type::DateTime
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Type-DateTime
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/PGObject-Type-DateTime
CPAN Ratings
http://cpanratings.perl.org/d/PGObject-Type-DateTime
Search CPAN
http://search.cpan.org/dist/PGObject-Type-DateTime/
Copyright 2013-2017 The LedgerSMB Core Team
This program is released under the following license: BSD
To install PGObject::Type::DateTime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PGObject::Type::DateTime
CPAN shell
perl -MCPAN -e shell install PGObject::Type::DateTime
For more information on module installation, please visit the detailed CPAN module installation guide.