Gumbo_Date



Date Class

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Implements interfaces:

Class Variables

int $_day =  1 [line 46]
array $_facts_day = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") [line 72]
array $_facts_month = array (1 => array ("name"=>"January", "days"=>31),2=>array("name"=>"February","days"=>28),3=>array("name"=>"March","days"=>31),4=>array("name"=>"April","days"=>30),5=>array("name"=>"May","days"=>31),6=>array("name"=>"June","days"=>30),7=>array("name"=>"July","days"=>31),8=>array("name"=>"August","days"=>31),9=>array("name"=>"September","days"=>30),10=>array("name"=>"October","days"=>31),11=>array("name"=>"November","days"=>30),12=>array("name"=>"December","days"=>31)) [line 58]
bool $_holiday =  false [line 55]
int $_hour =  0 [line 48]
int $_minute =  0 [line 50]
int $_month =  1 [line 44]
array $_orig [line 39]
int $_second =  0 [line 52]
int $_year =  2000 [line 42]

Class Methods

public static bool isLeapYear ( int $year ) [line 156]

Checks if the current year is a Leap Year

Parameter(s):

  • (int) $year
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::isLeapYear()

[ Top ]
public Gumbo_Date __construct ( string|int $stamp, [int $month], [int $day], [int $hour], [int $minute], [int $seconds] ) [line 131]

Constructor

Parameter(s):

  • (string|int) $stamp :: full date stamp, or year value
  • (int) $month
  • (int) $day
  • (int) $hour
  • (int) $minute
  • (int) $seconds

[ Top ]
public array diff ( Gumbo_Interface_Date $date ) [line 1786]

Returns the difference from the supplied Date

Parameter(s):

  • return:  [when|year|month|day|hour|minute|second]
Implementation of:
Gumbo_Interface_Date::diff()

[ Top ]
public int diffDay ( Gumbo_Interface_Date $val ) [line 1939]

Returns the number of Days difference

Parameter(s):

Implementation of:
Gumbo_Interface_Date::diffDay()

[ Top ]
public int diffMonth ( Gumbo_Interface_Date $val ) [line 1889]

Returns the number of Months difference

Parameter(s):

Implementation of:
Gumbo_Interface_Date::diffMonth()

[ Top ]
public int diffWeek ( Gumbo_Interface_Date $val ) [line 1914]

Returns the number of Weeks difference

Parameter(s):

Implementation of:
Gumbo_Interface_Date::diffWeek()

[ Top ]
public int diffYear ( int|Gumbo_Interface_Date $val ) [line 1861]

Returns the number of Years difference

Parameter(s):

Implementation of:
Gumbo_Interface_Date::diffYear()

[ Top ]
public int|string get ( [int $format] ) [line 1090]

Returns a Date string in predefined format

Format Codes:

  • 0 => yyyy-mm-dd hh:mm:ss (MySQL DATETIME)
  • 1 => yyyymm
  • 2 => yyyymmdd
  • 3 => yyyymmddhh
  • 4 => yyyymmddhhmm
  • 5 => yyyymmddhhmmss
  • 6 => UNIX EPOCH
To use more complex combinations, use a combination of the getDate() and getTime() methods.

Parameter(s):

  • (int) $format :: format code
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::get()

[ Top ]
public int|string getCentury ( [ $as_string] ) [line 1241]

Returns the Century

Parameter(s):

  • () $as_string
Implementation of:
Gumbo_Interface_Date::getCentury()

[ Top ]
public void getDate ( [string|int $format] ) [line 1143]

Returns a formatted Date string

Date Formats:

  • 0 => yyyy-mm-dd (default)
  • 1 => yyyymm
  • 2 => yyyymmdd
  • 3 => mm/dd/yyyy
  • 4 => [m]m/[d]d/yyyy
  • 5 => Mon [d]d[suffix], yyyy
  • 6 => Month [d]d[suffix], yyyy
  • 7 => Day, [d]d Mon yyyy
The method also uses the date() and strftime() functions. The format would have to be a string representing values the function will parse. If the percent sign (%) is found, it will use strftime(), else it will use date().

Parameter(s):

  • (string|int) $format :: pre-defined format code or string stamp
Implementation of:
Gumbo_Interface_Date::getDate()

[ Top ]
public int|string getDay ( [int $format] ) [line 1358]

Returns the Day in the requested format

Formats:

  • 0 => [d]d
  • 1 => dd
  • 2 => ## (numerical day of week)
  • 3 => Day (abbreviation)
  • 4 => Day (full name)
  • 5 => ## (day of year)

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getDay()

[ Top ]
public int|string getHour ( [int $format] ) [line 1399]

Returns the Hour in the requested format

Formats:

  • 0 => [h]h (24-hour format)
  • 1 => hh (24-hour format)
  • 2 => [h]h (12-hour format)
  • 3 => hh (12-hour format)

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getHour()

[ Top ]
public int|string getMinute ( [int $format] ) [line 1453]

Returns the Minutes in the requested format

Format:

  • 0 => [m]m
  • 1 => mm

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getMinute()

[ Top ]
public int|string getMonth ( [int $format] ) [line 1309]

Returns the Month in the requested format

Formats:

  1. -> [m]m
  2. -> mm
  3. -> Mon (abbreviation)
  4. -> Month (full name)

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getMonth()

[ Top ]
public array getMonthFacts ( ) [line 1530]

Returns an array of factual months

Implementation of:
Gumbo_Interface_Date::getMonthFacts()

[ Top ]
public int|string getSecond ( [int $format] ) [line 1494]

Returns the Seconds in the requested format

Format:

  • 0 => [s]s
  • 1 => ss

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getSecond()

[ Top ]
public string getTime ( [int $format] ) [line 1201]

Returns a formatted Time string

Time Format:

  • 0 => hh:mm:ss (default)
  • 1 => hh
  • 2 => hhmm
  • 3 => hhmmss
  • 4 => hh:mm
  • 5 => hh:mm [am|pm]
  • 6 => [h]h:mm
  • 7 => [h]h:mm [am|pm]
  • 8 => hh:mm:ss
  • 9 => hh:mm:ss [am|pm]
  • 10 => [h]h:mm:ss
  • 11 => [h]h:mm:ss [am|pm]

Parameter(s):

  • (int) $format :: pre-defined time format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getTime()

[ Top ]
public int getWeek ( ) [line 1339]

Returns the Week

Implementation of:
Gumbo_Interface_Date::getWeek()

[ Top ]
public int|string getYear ( [int $format] ) [line 1273]

Returns the Year requested format

Formats:

  1. -> yyyy
  2. -> yy

Parameter(s):

  • (int) $format
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::getYear()

[ Top ]
public bool isApril ( ) [line 1677]

Returns if April

Implementation of:
Gumbo_Interface_Date::isApril()

[ Top ]
public bool isAugust ( ) [line 1709]

Returns if August

Implementation of:
Gumbo_Interface_Date::isAugust()

[ Top ]
public bool isDecember ( ) [line 1741]

Returns if December

Implementation of:
Gumbo_Interface_Date::isDecember()

[ Top ]
public boolean isFall ( ) [line 1775]

Returns if Fall

Implementation of:
Gumbo_Interface_Date::isFall()

[ Top ]
public bool isFebruary ( ) [line 1661]

Returns if February

Implementation of:
Gumbo_Interface_Date::isFebruary()

[ Top ]
public bool isFriday ( ) [line 1635]

Returns if a Friday

Implementation of:
Gumbo_Interface_Date::isFriday()

[ Top ]
public bool isHoliday ( ) [line 1585]

Returns if the current day is a holiday

Implementation of:
Gumbo_Interface_Date::isHoliday()

[ Top ]
public bool isJanuary ( ) [line 1653]

Returns if January

Implementation of:
Gumbo_Interface_Date::isJanuary()

[ Top ]
public bool isJuly ( ) [line 1701]

Returns if July

Implementation of:
Gumbo_Interface_Date::isJuly()

[ Top ]
public bool isJune ( ) [line 1693]

Returns if June

Implementation of:
Gumbo_Interface_Date::isJune()

[ Top ]
public bool isMarch ( ) [line 1669]

Returns if March

Implementation of:
Gumbo_Interface_Date::isMarch()

[ Top ]
public bool isMay ( ) [line 1685]

Returns if May

Implementation of:
Gumbo_Interface_Date::isMay()

[ Top ]
public bool isMonday ( ) [line 1603]

Returns if a Monday

Implementation of:
Gumbo_Interface_Date::isMonday()

[ Top ]
public bool isNovember ( ) [line 1733]

Returns if November

Implementation of:
Gumbo_Interface_Date::isNovember()

[ Top ]
public bool isOctober ( ) [line 1725]

Returns if October

Implementation of:
Gumbo_Interface_Date::isOctober()

[ Top ]
public bool isSaturday ( ) [line 1643]

Returns if a Saturday

Implementation of:
Gumbo_Interface_Date::isSaturday()

[ Top ]
public bool isSeptember ( ) [line 1717]

Returns if September

Implementation of:
Gumbo_Interface_Date::isSeptember()

[ Top ]
public boolean isSpring ( ) [line 1759]

Returns if Spring

Implementation of:
Gumbo_Interface_Date::isSpring()

[ Top ]
public boolean isSummer ( ) [line 1767]

Returns if Summer

Implementation of:
Gumbo_Interface_Date::isSummer()

[ Top ]
public bool isSunday ( ) [line 1595]

Returns if a Sunday

Implementation of:
Gumbo_Interface_Date::isSunday()

[ Top ]
public bool isThursday ( ) [line 1627]

Returns if a Thursday

Implementation of:
Gumbo_Interface_Date::isThursday()

[ Top ]
public bool isTuesday ( ) [line 1611]

Returns if a Tuesday

Implementation of:
Gumbo_Interface_Date::isTuesday()

[ Top ]
public bool isWednesday ( ) [line 1619]

Returns if a Wednesday

Implementation of:
Gumbo_Interface_Date::isWednesday()

[ Top ]
public bool isWeekday ( ) [line 1577]

Returns if the current day is on the weekday

Implementation of:
Gumbo_Interface_Date::isWeekday()

[ Top ]
public bool isWeekend ( ) [line 1565]

Returns if the current day is on the weekend

Implementation of:
Gumbo_Interface_Date::isWeekend()

[ Top ]
public boolean isWinter ( ) [line 1751]

Returns if Winter

Implementation of:
Gumbo_Interface_Date::isWinter()

[ Top ]
public string meridien ( [bool $in_caps] ) [line 1967]

Returns the AM/PM time value

Parameter(s):

  • (bool) $in_caps :: returns value in caps
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::meridien()

[ Top ]
public void nextDay ( [int $num] ) [line 362]

Increases the Day

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextDay()

[ Top ]
public void nextHour ( [int $num] ) [line 400]

Increases the Hour

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextHour()

[ Top ]
public void nextMinute ( [int $num] ) [line 433]

Increases the Minutes

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextMinute()

[ Top ]
public void nextMonth ( [int $num] ) [line 299]

Increases the Month by number.

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextMonth()

[ Top ]
public void nextSecond ( [int $num] ) [line 466]

Increases the Seconds

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextSecond()

[ Top ]
public void nextWeek ( [int $num] ) [line 333]

Increases the Week

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextWeek()

[ Top ]
public void nextYear ( [int $num] ) [line 270]

Increases the Year by number

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::nextYear()

[ Top ]
public void prevDay ( [int $num] ) [line 591]

Decreases the Day

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevDay()

[ Top ]
public void prevHour ( [int $num] ) [line 629]

Decreases the Hour

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevHour()

[ Top ]
public void prevMinute ( [int $num] ) [line 662]

Decreases the Minutes

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevMinute()

[ Top ]
public void prevMonth ( [int $num] ) [line 529]

Decreases the Month

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevMonth()

[ Top ]
public void prevSecond ( [int $num] ) [line 695]

Decreases the Seconds

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevSecond()

[ Top ]
public void prevWeek ( [int $num] ) [line 562]

Decreases the Week

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevWeek()

[ Top ]
public void prevYear ( [int $num] ) [line 499]

Decreases the Year

Parameter(s):

  • (int) $num
  • precondition:  $num > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::prevYear()

[ Top ]
public void reset ( ) [line 188]

Resets the state to the original time stamp

Implementation of:
Gumbo_Interface_Date::reset()

[ Top ]
public void setDate ( int $year, int $month, int $day ) [line 792]

Sets the Date values of the object

Parameter(s):

  • (int) $year
  • (int) $month
  • (int) $day
Implementation of:
Gumbo_Interface_Date::setDate()

[ Top ]
public void setDateEpoch ( int $time ) [line 834]

Sets the Date by the UNIX Epoch

Parameter(s):

  • (int) $time
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setDateEpoch()

[ Top ]
public void setDateStamp ( mixed $stamp ) [line 815]

Sets the Date by a stamp parsed down to yyyymmdd[hhmmss] format

Parameter(s):

  • (mixed) $stamp
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setDateStamp()

[ Top ]
public void setDay ( int $day ) [line 920]

Sets the Day

Parameter(s):

  • (int) $day
  • precondition:  0 < $val <= 31
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setDay()

[ Top ]
public void setHoliday ( bool $val ) [line 773]

Marks the Date as a Holiday

Parameter(s):

  • (bool) $val
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setHoliday()

[ Top ]
public void setHour ( int $hour ) [line 954]

Sets the Hour

Parameter(s):

  • (int) $hour
  • precondition:  0 <= $val < 24
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setHour()

[ Top ]
public void setMinute ( int $min ) [line 977]

Sets the Minute

Parameter(s):

  • (int) $min
  • precondition:  0 <= $val < 60
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setMinute()

[ Top ]
public void setMonth ( int|string $month ) [line 881]

Sets the Month

The value can be the numberical month, a three-letter abbreviation of the month name, or the full name.

Parameter(s):

  • (int|string) $month
  • precondition:  if int, 0 < $val < 13
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setMonth()

[ Top ]
public void setSeconds ( int $sec ) [line 1000]

Sets the Seconds

Parameter(s):

  • (int) $sec
  • precondition:  0 <= $val < 60
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setSeconds()

[ Top ]
public void setTime ( int $hour, int $minutes, int $seconds ) [line 804]

Sets the Time values of object

Parameter(s):

  • (int) $hour
  • (int) $minutes
  • (int) $seconds
Implementation of:
Gumbo_Interface_Date::setTime()

[ Top ]
public void setYear ( int $year ) [line 854]

Sets the Year

Parameter(s):

  • (int) $year
  • precondition:  $val > 0
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::setYear()

[ Top ]
public int totalDays ( [int $month] ) [line 1540]

Returns the total days within a month

Parameter(s):

  • (int) $month
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Date::totalDays()

[ Top ]
public void zeroHour ( ) [line 200]

Sets the time to the zero hour

  • postcondition:  $hour=0
  • postcondition:  $minutes=0
  • postcondition:  $seconds=0
Implementation of:
Gumbo_Interface_Date::zeroHour()

[ Top ]
private int _calcDayOfWeek ( ) [line 208]

Calculates the current Day of the Week


[ Top ]
private int _calcDayOfYear ( ) [line 241]

Calculates the Day of the Year


[ Top ]
private int _calcWeekOfYear ( ) [line 259]

Calculates the Week of the Year


[ Top ]
private void _change ( int $num, string $method ) [line 1038]

Changes the particular element by the supplied number

Parameter(s):

  • (int) $num :: number to increase/decrease
  • (string) $method :: Date method to call
  • throws:  Gumbo_Exception

[ Top ]
private array _getOrigStamp ( ) [line 1068]

Returns the original time stamp

  • return:  as [year|month|day]

[ Top ]
private void _parse ( string|int $stamp ) [line 1021]

Parses the timestamp into Date components

Parameter(s):

  • (string|int) $stamp

[ Top ]
private void _setOrigStamp ( int $year, int $month, int $day, int $hour, int $minute, int $second ) [line 735]

Sets the original time stamp

Parameter(s):

  • (int) $year
  • (int) $month
  • (int) $day
  • (int) $hour
  • (int) $minute
  • (int) $second
  • throws:  Gumbo_Exception

[ Top ]

Class Constants

DAYS_IN_LEAP_YEAR = [line 80]
DAYS_IN_WEEK = [line 82]
DAYS_IN_YEAR = [line 78]
HOURS_IN_DAY = [line 88]
HOURS_IN_LEAP_YEAR = [line 94]
HOURS_IN_WEEK = [line 90]
HOURS_IN_YEAR = [line 92]
MINUTES_IN_DAY = [line 99]
MINUTES_IN_HOUR = [line 97]
MINUTES_IN_LEAP_YEAR = [line 105]
MINUTES_IN_WEEK = [line 101]
MINUTES_IN_YEAR = [line 103]
MONTHS_IN_YEAR = [line 75]
SECONDS_IN_DAY = [line 112]
SECONDS_IN_HOUR = [line 110]
SECONDS_IN_LEAP_YEAR = [line 118]
SECONDS_IN_MINUTE = [line 108]
SECONDS_IN_WEEK = [line 114]
SECONDS_IN_YEAR = [line 116]
WEEKS_IN_YEAR = [line 85]