## Class TDateTimeStamp

Description

TDateTimeStamp Class

TDateTimeStamp Class is adpated from the ADOdb Date Library, part of the ADOdb abstraction library Download: http://phplens.com/phpeverywhere/

http://phplens.com/phpeverywhere/adodb_date_library

PHP native date functions use integer timestamps for computations. Because of this, dates are restricted to the years 1901-2038 on Unix and 1970-2038 on Windows due to integer overflow for dates beyond those years. This library overcomes these limitations by replacing the native function's signed integers (normally 32-bits) with PHP floating point numbers (normally 64-bits).

Dates from 100 A.D. to 3000 A.D. and later have been tested. The minimum is 100 A.D. as <100 will invoke the 2 => 4 digit year conversion. The maximum is billions of years in the future, but this is a theoretical limit as the computation of that year would take too long with the current implementation of getTimeStamp.

PERFORMANCE For high speed, this library uses the native date functions where possible, and only switches to PHP code when the dates fall outside the 32-bit signed integer range.

- since: 3.0.4
- version: $Id: TDateTimeStamp.php 2488 2008-08-06 01:34:06Z knut $
- author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /Util/TDateTimeStamp.php (line 66)

Variable Summary
mixed $_month_leaf
mixed $_month_normal
Method Summary
integer digitCheck (mixed $y)
string formatDate (mixed $fmt, [mixed $d = false], [mixed $is_gmt = false])
void get4DigitYear (mixed $y)
array getDate ([mixed $d = false], [mixed $fast = false])
void getDayofWeek (mixed $year, mixed $month, mixed $day)
integer getGMTDiff ()
integer|float getTimeStamp (mixed $hr, mixed $min, mixed $sec, [mixed $mon = false], [mixed $day = false], [mixed $year = false], [mixed $is_gmt = false])
boolean isLeapYear (float $year)
boolean isValidDate (mixed $y, mixed $m, mixed $d)
array _getDateInternal ([float $origd = false], [boolean $fast = true], [boolean $is_gmt = false])
Variables
mixed $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31) (line 69)

- static:
- access: protected

mixed $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31) (line 68)

- static:
- access: protected

Methods
digitCheck (line 143)

Fix 2-digit years. Works for any century.

Assumes that if 2-digit is more than 30 years in future, then previous century.

- return: change two digit year into multiple digits
- access: protected

integer digitCheck (mixed $y)
formatDate (line 444)

- return: formatted date based on timestamp $d

string formatDate (mixed $fmt, [mixed $d = false], [mixed $is_gmt = false])
get4DigitYear (line 165)

- access: public

void get4DigitYear (mixed $y)
getDate (line 185)

- return: an array with date info.

array getDate ([mixed $d = false], [mixed $fast = false])
getDayofWeek (line 75)

Gets day of week, 0 = Sunday,... 6=Saturday.

Algorithm from PEAR::Date_Calc

- access: public

void getDayofWeek (mixed $year, mixed $month, mixed $day)
getGMTDiff (line 173)

- return: get local time zone offset from GMT
- access: public

integer getGMTDiff ()
getTimeStamp (line 598)

Not a very fast algorithm - O(n) operation. Could be optimized to O(1).

- return: a timestamp given a local time. Originally by jackbbs.

integer|float getTimeStamp (mixed $hr, mixed $min, mixed $sec, [mixed $mon = false], [mixed $day = false], [mixed $year = false], [mixed $is_gmt = false])
isLeapYear (line 124)

Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly.

- return: true if is leap year
- access: public

boolean isLeapYear (float $year)

- float $year: year to check

isValidDate (line 423)

- return: true if valid date, semantic check only.
- access: public

boolean isValidDate (mixed $y, mixed $m, mixed $d)
_getDateInternal (line 208)

Low-level function that returns the getdate() array. We have a special $fast flag, which if set to true, will return fewer array values, and is much faster as it does not calculate dow, etc.

- return: an array with date info.
- access: protected

array _getDateInternal ([float $origd = false], [boolean $fast = true], [boolean $is_gmt = false])

- float $origd: original date
- boolean $fast: false to compute the day of the week, default is true
- boolean $is_gmt: true to calculate the GMT dates

Documentation generated on Mon, 22 Feb 2010 12:17:33 +0000 by phpDocumentor 1.3.0RC4