NAME
Solstice::DateTime - Models a point in time.
SYNOPSIS
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
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
Modules Used
AUTHOR
Catalyst Group, <catalyst@u.washington.edu>
VERSION
$Revision: 3364 $
COPYRIGHT
Copyright 1998-2007 Office of Learning Technologies, University of Washington
Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.