SYNOPSIS

   use Tangram;

   # any of:
   use Tangram::Type::Date;   # RAW - use with caution
   use Tangram::Type::Time;
   use Tangram::Type::Date::Cooked;   # pure ISO-8601
   use Tangram::Type::Date::DateTime;
   use Tangram::Type::Date::Manip;
   use Tangram::Type::Date::TimePiece;

   Tangram::Schema->new(
      classes => {
          NaturalPerson => {
             fields => {
                 rawdatetime => [ qw( birth death ) ],
                 rawdate => [ qw( depart return ) ],
                 rawtime => [ qw( breakfast lunch dinner ) ],
                 cookeddatetime => [ qw( cooked ) ],
                 dmdatetime => [ qw( datemanip ) ],
                 timepiece => [ qw( fob ) ],
                 datetime => [ qw( bloat ) ],

DESCRIPTION

These classes are responsible for mapping strings to \s-1SQL\s0 date or time types. These classes are not imported by Tangram.pm, thus they must be explicitly imported via a \*(C`use\*(C' directive.

The three typetags \*(C`rawdate\*(C', \*(C`rawtime\*(C' and \*(C`rawdatetime\*(C' are for mapping strings to \s-1SQL\s0 date/time types, for databases that differentiate between \*(L"dates\*(R" and \*(L"times\*(R". 'Raw' means that Tangram doesn't attempt to interpret the strings, it merely passes them down to \s-1DBI\s0.

\*(C`cookeddatetime\*(C' is like \*(C`rawdatetime\*(C' except that the date is converted from the \s-1DBMS\s0 format to \s-1ISO-8601\s0 in the form :

YYYY-MM-DDTHH:MM:SS

for example:

2004-12-25T13:14:15

Other modules then further cook this \s-1ISO\s0 date into an object as is the convention for a particular module. This only works with back-ends that allow per-connection settings for the default date format, such as Tangram::Driver::Oracle.

On the way back out, the date is converted back to the \s-1DBMS\s0 format. This is achieved via vendor-specific functions mentioned in \*(C`Tangram::Relational\*(C'.

The persistent fields may be specified either as a hash or as an array of field names.

In the hash form, each entry consists in a field name and an associated option hash. The option hash may contain the following fields:

  • col

  • sql

\*(C`col\*(C' sets the name of the column used to store the field's value. This field is optional, it defaults to the persistent field name. Override if the field name is not an acceptable \s-1SQL\s0 column name.

\*(C`sql\*(C' sets the \s-1SQL\s0 type of the column. Used by Schema::deploy() when initializing a database. Defaults to '\s-1VARCHAR\s0(255) \s-1NULL\s0' for strings, '\s-1INT\s0 \s-1NULL\s0' for ints and '\s-1REAL\s0 \s-1NULL\s0' for reals.

The persistent fields may also be specified as an array of strings, in which case the defaults are used.