Solstice::DateTime - Models a point in time.


Solstice documentation  | view source Contained in the Solstice distribution.

Index


NAME

Top

Solstice::DateTime - Models a point in time.

SYNOPSIS

Top

  use Solstice::DateTime;

  my $dt = new Solstice::DateTime(time());
  my $dt = new Solstice::DateTime('2005-03-11 02:34:12');
  my $dt = new Solstice::DateTime('now');

  # These functions return the object
  $date_time->addYears($year_count);
  $date_time->addMonths($month_count);
  $date_time->addDays($day_count);

DESCRIPTION

Top

Export

No symbols exported.

Methods

new([$input])

Constructor. Returns a DateTime object.

setDate($year, $month, $day)

Sets the date

setTime($hour, $min, $sec [, $ampm])

Sets the time

clone()

Returns a duplicate DateTime object.

addYears($years)

Add some number of years to the date.

addMonths($months)

Add some number of months to the date.

addDays($days)

Add some number of days to the date

addHours($hours)

Add some number of hours to the date

addMinutes($min)

Add some number of min to the date

addSeconds($sec)

Add some number of seconds to the date

getYear()
getMonth()
getDay()
getHour()
getMin()
getSec()
isValidDate()

Validate the date values as forming a valid date. Date::Calc::check_date does the heavy work.

isValidTime()

Validate the time values as forming a valid time. Date::Calc::check_time does the heavy work.

isValid()

Returns a boolean specifying whether the obj datetime is valid

isEmpty()

Returns a boolean specifying whether the obj contains a datetime

isEqualTo($datetime)

Returns a boolean specifying whether the obj datetime is equal to the passed datetime.

isSameDay($datetime)

Returns a boolean specifying whether the obj datetime is the same date to the passed in datetime

isBefore($datetime)

Returns a boolean specifying whether the obj datetime is before the passed datetime.

isBeforeNow()

Returns a boolean specifying whether the obj datetime is before now.

getDaysApart($datetime)

Returns the number of days apart the 2 datetime objects are, as a float. Returns 0 if either is invalid.

getTimeApart($datetime)

Returns the number of seconds apart the 2 datetime objects are. Returns 0 if either is invalid.

toSQL()

Returns an SQL formatted date

toISO()

Returns an ISO 8601 formatted date

toCommon()

Returns a human-readable date string

toMovingWindow()

Return a formatted string, that displays a moving 3-day window

toUnix()

Returns a Unix formatted date (epoch seconds)

toString($format)

Returns a formatted datetime string; $format contains a strftime-style formatting string. Date validity is not implicit.

cmpDate($date)

Takes a date object and compares it to itself.

Private Methods

_init($input)
_addYMD($y, $m, $d)

Does the heavy lifting for addDays, addMonths, and addYears.

_updateToNow()

Update the date if the DateTime obj is a 'now' obj

Private Functions

_getAccessorDefinition()

Modules Used

Date::Format.

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 3364 $

COPYRIGHT

Top


Solstice documentation  | view source Contained in the Solstice distribution.