Oryx::Value::DateTime - Values storing dates and times


Oryx documentation Contained in the Oryx distribution.

Index


Code Index:

NAME

Top

Oryx::Value::DateTime - Values storing dates and times

SYNOPSIS

Top

  package CMS::Event;

  use base qw( Oryx::Class );

  use Class::Date qw( now );

  our $schema = {
      attributes => [ {
          name => 'summary',
          type => 'String',
      }, {
          name => 'when',
          type => 'DateTime',
      } ],
  };

  $x = CMS::Event->create({
      summary => 'Meet with Joe',
      when    => now,
  });

DESCRIPTION

Top

This type stores dates and times by using Class::Date objects.

This value will check to see that the value stored is a proper date and will inflate and deflate the date using Class::Date to be stored in a "DateTime" primitive type field.

SEE ALSO

Top

Class::Date, Oryx::Value

AUTHOR

Top

Richard Hundt <richard NO SPAM AT protea-systems.com>

COPYRIGHT AND LICENSE

Top


Oryx documentation Contained in the Oryx distribution.

package Oryx::Value::DateTime;

use base qw(Oryx::Value);
use Class::Date qw(:errors date);

sub primitive { 'DateTime' }

sub check_type {
    my ($self, $value) = @_;
    my $date = date($value);
    if ($date->error == E_INVALID) {
	return 0;
    }
    return 1;
}

sub inflate {
    my ($self, $value) = @_;
    return date($value);
}

sub deflate {
    my ($self, $value) = @_;
    return date($value)->string;
}

1;
__END__