NAME

Podius::Property::Date - scalar component property


SYNOPSIS

        my $property = new Podius::Property::Date;
        $property->access(20070717);
        print $property->as_string;


DESCRIPTION

This module implements component property representing a date.


REQUIREMENTS

the Podius::Integer manpage.


FUNCTIONS

time_to_date [time]
Converts unix time to the date format, that is an integer YYYYMMDD. Without a parameter the today's value is taken. Special suported time values are ``today'', ``yesterday'', ``tomorrow''.

get_year_month_day date
This is both method (see below) and function. If the first parameter is an object, then its date value is taken, otherwise the first parameter is taken as the date value.


METHODS

access

parameters
Accessor: none.

Modifier: property value to set. undef means unset the value.

Supported formats are:

  * 20070513
  * "2007-05-13"
  * "2007/05/13"
  * "2007.05.13"
  * "13-05-2007"
  * "13/05/2007"
  * "13.05.2007"
  * "2007-05-13 12:34:45"
  * "13-05-2007 12:34:45"
  * 1179048885 (10 digits, unix time for "2007-05-13 12:34:45 IDT")
  * "today", "yesterday", "tomorrow"

These non-zero padded or space-padded fields are supported too:

  * "2007-5-3"
  * "2007-5-3 8:8:8"
  * "2007- 5- 3"
  * "2007- 5- 3  8: 8: 8"

Partial dates (representing some month, some year or no-date rather than some day) are supported too:

  * 20070500
  * 20070000
  * 00000000 or 00000 or 0 or undef (stored as "00000")

The stored value always has 8 digits in normal situations.

For dates before the year 1000, the stored value may have less than 8 digits, but better prepend zeros. The dates before the era (negative) are supported too. In both these cases, only the input forms like [-]YYYMMDD and ``[-]YYY-MM-DD'' are valid.

returns
Property value. ``00000'' means no date is set.

get_year_month_day

returns
Three strings of 4, 2 and 2 digits (the year, month and day of the date).

format [format]

as_string [format]

access_as_string [format]

returns
Returns formatted date string. The default format is ``%Y-%m-%d'' that is ``YYYY-MM-DD''.

access_year

parameters
Only accessor form of the method is available.

returns
The string containing 4 digits (the year of the date).

access_month

parameters
Only accessor form of the method is available.

returns
The string containing 2 digits (the month of the date).

access_day

parameters
Only accessor form of the method is available.

returns
The string containing 2 digits (the day of the date).

has_year

has_month

has_day

returns
The boolean that means the year or month or day part of the date is set. (If the month is set it is guaranteed that the month is set and so on.)