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.

  • author: Wei Zhuo <weizhuo[at]gmail[dot]com>
  • version: $Id: TDateTimeStamp.php 2996 2011-06-20 15:24:57Z ctrlaltca@gmail.com $
  • since: 3.0.4

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


	
			
Variable Summary
static mixed $_month_leaf
static mixed $_month_normal
Method Summary
integer digitCheck ( $y)
string formatDate ( $fmt, [ $d = false], [ $is_gmt = false])
void get4DigitYear ( $y)
array getDate ([ $d = false], [ $fast = false])
void getDayofWeek ( $year,  $month,  $day)
integer getGMTDiff ()
integer|float getTimeStamp ( $hr,  $min,  $sec, [ $mon = false], [ $day = false], [ $year = false], [ $is_gmt = false])
boolean isLeapYear (float $year)
boolean isValidDate ( $y,  $m,  $d)
array _getDateInternal ([float $origd = false], [boolean $fast = true], [boolean $is_gmt = false])
Variables
static mixed $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31) (line 69)
  • access: protected
static mixed $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31) (line 68)
  • 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 ( $y)
  • $y
formatDate (line 444)
  • return: formatted date based on timestamp $d
string formatDate ( $fmt, [ $d = false], [ $is_gmt = false])
  • $fmt
  • $d
  • $is_gmt
get4DigitYear (line 165)
  • access: public
void get4DigitYear ( $y)
  • $y
getDate (line 185)
  • return: an array with date info.
array getDate ([ $d = false], [ $fast = false])
  • $d
  • $fast
getDayofWeek (line 75)

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

Algorithm from PEAR::Date_Calc

  • access: public
void getDayofWeek ( $year,  $month,  $day)
  • $year
  • $month
  • $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 ( $hr,  $min,  $sec, [ $mon = false], [ $day = false], [ $year = false], [ $is_gmt = false])
  • $hr
  • $min
  • $sec
  • $mon
  • $day
  • $year
  • $is_gmt
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 ( $y,  $m,  $d)
  • $y
  • $m
  • $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, 25 Jun 2012 14:37:58 +0200 by phpDocumentor 1.4.3