The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

Object::Relation::DataType::DateTime::Incomplete - Incomplete Object::Relation DateTime objects

Synopsis

  my $dt = Object::Relation::DataType::DateTime::Incomplete->new(
    month  => 10,
    day    => 16,
  );

Description

This module subclasses the DateTime::Incomplete module to offer DateTime::Incomplete objects to Object::Relation applications. The only way in which it differs from DateTime::Incomplete is that all new Object::Relation::DataType::DateTime objects are in the "UTC" time zone unless another time zone is specified and it knows to properly stringify itself when accessed by Object::Relation::Handle.

Class Interface

Constructors

new

  my $dt = Object::Relation::DataType::DateTime::Incomplete->new(
    month  => 10,
    day    => 16,
  );

Constructs and returns a new Object::Relation::DataType::DateTime::Incomplete object. Unless a time zone is specified, the time zone will be UTC.

bake

  my $dt = Object::Relation::DataType::DateTime->bake('1964-10-16T16:12:47.0');

Same as new but takes an incomplete iso8601 date string as the argument.

contiguous

  if ($date->contiguous) { ... }

This method returns a true or false value depending upon whether or not all of the date components are contiguous. For example, "month, day and hour" are contiguous, but "month, day, and minute" are not.

This method will return false if none of the date components are defined.

is_incomplete_iso8601

  use Object::Relation::DataType::DateTime::Incomplete qw/is_incomplete_iso8601/;
  if (is_incomplete_iso8601('1964-xx-16T16:12:47.0')) {
    ...
  }

Returns a true or false value depending upon whether or not the supplied string matches an incomplete ISO 8601 datetime string. This is a function, not a method.

If a particular date segment is not present, it may be replaced with 'Xs'. However, the complete date segment must be replaced. For example, you can replace the year 1968 with 'xxxx', but not '19xx'. If nanoseconds are not present, omit them.

Currently ignores timezone.

It won't match:

 1964-10-16T17:12:47.0 # the date is not incomplete
 1964-10-16 17:12:47.0 # missing the "T"
 xx64-10-16T17:12:47.0 # year segment only partially replaced

Valid incomplete datetime strings:

 xxxx-10-16T17:12:47.0 
 1964-xx-16T17:12:47.0 
 1964-xx-xxT17:xx:xx.0 
 1964-10-16T17:12:xx

defined_store_fields

  my @fields = $date->defined_store_fields;

This method returns a list of all defined fields which are also valid for the data stores.

sort_string

  my $sortable_string = $date->sort_string;

Returns the date in a string format suitable for sorting. There are no component separators and undefined components are omitted. All components except year are zero padded to 2 characters. The year is zero padded with four characters.

  '19970623' eq Object::Relation::DataType::DateTime::Incomplete->new(
    year  => 1997,
    month => 6,
    hour  => 23
  )->sort_string;

same_segments

  if ($date->same_segments($other_date)) {
    ...
  }

Returns a boolean value indicating whether or not two dates have the same segments defined.

Copyright and License

Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.