NAME

PGObject::Type::DateTime - DateTime Wrappers for PGObject

VERSION

Version 1.0.4

SYNOPSIS

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.

DESCRIPTION

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.

SUBROUTINES/METHODS

register

By default registers 'date', 'time', 'timestamp', and 'timestamptz'

_new

Constructor for the PGDate object. Fully compliant with 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.

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.

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.

SUPPORT

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

perldoc PGObject::Type::DateTime

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2013 Chris Travers.

This program is released under the following license: BSD