dev.obliquid.com: pear
[ class tree: pear ] [ index: pear ] [ all elements ]

Class: Date_Calc

Source Location: Program_Root/classes/pear/Date/Calc.php

Class Overview


Class Date_Calc


Methods


Inherited Variables

Inherited Methods


Class Details

[line 34]
Class Date_Calc





[ Top ]


Class Methods


method beginOfMonth [line 861]

string beginOfMonth( [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Return date of first day of month of given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $month   year in format CCYY, default current local year
string   $year   month in format MM, default current local month
string   $format   format for returned date

[ Top ]

method beginOfNextMonth [line 317]

string beginOfNextMonth( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of begin of next month of given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method beginOfNextWeek [line 964]

string beginOfNextWeek( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Find the month day of the beginning of week after given date, using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method beginOfPrevMonth [line 394]

string beginOfPrevMonth( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the first day of previous month of given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method beginOfPrevWeek [line 1002]

string beginOfPrevWeek( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Find the month day of the beginning of week before given date, using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method beginOfWeek [line 886]

string beginOfWeek( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Find the month day of the beginning of week for given date, using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method dateDiff [line 748]

int dateDiff( string $day1, string $month1, string $year1, string $day2, string $month2, string $year2)

Returns number of days between two given dates.



Tags:

return:  absolute number of days between dates, -1 if there is an error.
access:  public


Parameters:

string   $day1   year in format CCYY
string   $month1   month in format MM
string   $year1   day in format DD
string   $day2   year in format CCYY
string   $month2   month in format MM
string   $year2   day in format DD

[ Top ]

method dateFormat [line 1300]

string dateFormat( string $day, string $month, string $year, string $format)

Formats the date in the given format, much like strfmt(). This function is used to alleviate the problem with 32-bit numbers for dates pre 1970 or post 2038, as strfmt() has on most systems.

Most of the formatting options are compatible.

formatting options:

%a abbreviated weekday name (Sun, Mon, Tue) %A full weekday name (Sunday, Monday, Tuesday) %b abbreviated month name (Jan, Feb, Mar) %B full month name (January, February, March) %d day of month (range 00 to 31) %e day of month, single digit (range 0 to 31) %E number of days since unspecified epoch (integer) (%E is useful for passing a date in a URL as an integer value. Then simply use daysToDate() to convert back to a date.) %j day of year (range 001 to 366) %m month as decimal number (range 1 to 12) %n newline character (\n) %t tab character (\t) %w weekday as decimal (0 = Sunday) %U week number of current year, first sunday as first week %y year as decimal (range 00 to 99) %Y year as decimal including century (range 0000 to 9999) %% literal '%'




Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY
string   $month   month in format MM
string   $year   day in format DD
string   $format   format for returned date

[ Top ]

method dateNow [line 48]

string dateNow( [string $format = "%Y%m%d"])

Returns the current local date. NOTE: This function retrieves the local date using strftime(), which may or may not be 32-bit safe on your system.



Tags:

return:  the current date in specified format
access:  public


Parameters:

string   $format   the strftime() format to return the date

[ Top ]

method dateToDays [line 1155]

integer dateToDays( string $day, string $month, string $year)

Converts a date to number of days since a distant unspecified epoch.



Tags:

return:  number of days
access:  public


Parameters:

string   $day   year in format CCYY
string   $month   month in format MM
string   $year   day in format DD

[ Top ]

method dayOfWeek [line 183]

int dayOfWeek( [string $day = ""], [string $month = ""], [string $year = ""])

Returns day of week for given date, 0=Sunday



Tags:

access:  public


Parameters:

string   $day   year in format CCYY, default is current local year
string   $month   month in format MM, default is current local month
string   $year   day in format DD, default is current local day

[ Top ]

method daysInMonth [line 770]

int daysInMonth( [string $month = ""], [mixed $year = ""])

Find the number of days in the given month.



Tags:

return:  number of days
access:  public


Parameters:

string   $month   month in format MM, default current local month

[ Top ]

method daysToDate [line 1193]

string daysToDate( int $days, [string $format = "%Y%m%d"])

Converts number of days to a distant unspecified epoch.



Tags:

return:  date in specified format
access:  public


Parameters:

int   $days   number of days
string   $format   format for returned date

[ Top ]

method defaultCentury [line 721]

string defaultCentury( string $year)

Sets century for 2 digit year.

51-99 is 19, else 20




Tags:

return:  4 digit year
access:  public


Parameters:

string   $year   2 digit year

[ Top ]

method endOfNextMonth [line 355]

string endOfNextMonth( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the last day of next month of given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method endOfPrevMonth [line 432]

string endOfPrevMonth( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the last day of previous month for given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method endOfWeek [line 932]

string endOfWeek( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Find the month day of the end of week for given date, using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of following month.)



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method firstOfMonthWeekday [line 838]

int firstOfMonthWeekday( [string $month = ""], [string $year = ""])

Find the day of the week for the first of the month of given date.



Tags:

return:  number of weekday for the first day, 0=Sunday
access:  public


Parameters:

string   $month   year in format CCYY, default to current local year
string   $year   month in format MM, default to current local month

[ Top ]

method getCalendarMonth [line 1077]

array getCalendarMonth( [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Return a set of arrays to construct a calendar month for the given date.



Tags:

access:  public


Parameters:

string   $month   year in format CCYY, default current local year
string   $year   month in format MM, default current local month
string   $format   format for returned date

[ Top ]

method getCalendarWeek [line 1039]

array getCalendarWeek( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Return an array with days in week



Tags:

access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method getCalendarYear [line 1128]

array getCalendarYear( [string $year = ""], [string $format = "%Y%m%d"])

Return a set of arrays to construct a calendar year for the given date.



Tags:

access:  public


Parameters:

string   $year   year in format CCYY, default current local year
string   $format   format for returned date

[ Top ]

method getDay [line 1417]

string getDay( )

Returns the current local day in format DD



Tags:

return:  day in format DD
access:  public


[ Top ]

method getMonth [line 1403]

string getMonth( )

Returns the current local month in format MM



Tags:

return:  month in format MM
access:  public


[ Top ]

method getMonthAbbrname [line 1459]

string getMonthAbbrname( string $month, [int $length = 3])

Returns the abbreviated month name for the given month



Tags:

return:  abbreviated month name
see:  Date_Calc::getMonthFullname
access:  public


Parameters:

string   $month   month in format MM
int   $length   optional length of abbreviation, default is 3

[ Top ]

method getMonthFromFullName [line 1530]

integer getMonthFromFullName( string $month)

Returns the numeric month from the month name or an abreviation

Both August and Aug would return 8. Month name is case insensitive.




Tags:

return:  month number


Parameters:

string   $month   month name

[ Top ]

method getMonthFullname [line 1433]

string getMonthFullname( string $month)

Returns the full month name for the given month



Tags:

return:  full month name
access:  public


Parameters:

string   $month   month in format MM

[ Top ]

method getMonthNames [line 1550]

array getMonthNames( )

Retunrs an array of month names

Used to take advantage of the setlocale function to return language specific month names. XXX cache values to some global array to avoid preformace hits when called more than once.




Tags:

return:  An array of month names


[ Top ]

method getWeekdayAbbrname [line 1510]

string getWeekdayAbbrname( [string $day = ""], [string $month = ""], [string $year = ""], [int $length = 3])

Returns the abbreviated weekday name for the given date



Tags:

return:  full month name
see:  Date_Calc::getWeekdayFullname
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
int   $length   optional length of abbreviation, default is 3

[ Top ]

method getWeekdayFullname [line 1480]

string getWeekdayFullname( [string $day = ""], [string $month = ""], [string $year = ""])

Returns the full weekday name for the given date



Tags:

return:  full month name
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day

[ Top ]

method getWeekDays [line 1566]

array getWeekDays( )

Returns an array of week days

Used to take advantage of the setlocale function to return language specific week days XXX cache values to some global array to avoid preformace hits when called more than once.




Tags:

return:  An array of week day names


[ Top ]

method getYear [line 1389]

string getYear( )

Returns the current local year in format CCYY



Tags:

return:  year in format CCYY
access:  public


[ Top ]

method isFutureDate [line 119]

boolean isFutureDate( string $day, string $month, string $year)

Determines if given date is a future date from now.



Tags:

return:  true/false
access:  public


Parameters:

string   $day   year in format CCYY
string   $month   month in format MM
string   $year   day in format DD

[ Top ]

method isLeapYear [line 91]

void isLeapYear( [mixed $year = ""])





[ Top ]

method isPastDate [line 151]

boolean isPastDate( string $day, string $month, string $year)

Determines if given date is a past date from now.



Tags:

return:  true/false
access:  public


Parameters:

string   $day   year in format CCYY
string   $month   month in format MM
string   $year   day in format DD

[ Top ]

method isValidDate [line 66]

boolean isValidDate( string $day, string $month, string $year)

Returns true for valid date, false for invalid date.



Tags:

return:  true/false
access:  public


Parameters:

string   $day   year in format CCYY
string   $month   month in format MM
string   $year   day in format DD

[ Top ]

method julianDate [line 257]

int julianDate( [string $day = ""], [string $month = ""], [string $year = ""])

Returns number of days since 31 December of year before given date.



Tags:

access:  public


Parameters:

string   $day   year in format CCYY, default is current local year
string   $month   month in format MM, default is current local month
string   $year   day in format DD, default is current local day

[ Top ]

method nextDay [line 667]

string nextDay( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of day after given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method nextDayOfWeek [line 545]

string nextDayOfWeek( int $dow, [string $day = ""], [string $month = ""], [string $year = ""], [boolean $format = "%Y%m%d"], [string $onOrAfter = false])

Returns date of the next specific day of the week from the given date.



Tags:

return:  date in given format
access:  public


Parameters:

int   $dow   day of week, 0=Sunday
string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
boolean   $format   onOrAfter if true and days are same, returns current day
string   $onOrAfter   format for returned date

[ Top ]

method nextDayOfWeekOnOrAfter [line 628]

string nextDayOfWeekOnOrAfter( int $dow, [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the next specific day of the week on or before the given date.



Tags:

return:  date in given format
access:  public


Parameters:

int   $dow   day of week, 0=Sunday
string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method nextWeekday [line 471]

string nextWeekday( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the next weekday of given date, skipping from Friday to Monday.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method NWeekdayOfMonth [line 1243]

string NWeekdayOfMonth( string $occurance, string $dayOfWeek, string $month, string $year, [string $format = "%Y%m%d"])

Calculates the date of the Nth weekday of the month, such as the second Saturday of January 2000.



Tags:

return:  date in given format
access:  public


Parameters:

string   $occurance   occurance: 1=first, 2=second, 3=third, etc.
string   $dayOfWeek   dayOfWeek: 0=Sunday, 1=Monday, etc.
string   $month   year in format CCYY
string   $year   month in format MM
string   $format   format for returned date

[ Top ]

method prevDay [line 695]

string prevDay( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of day before given date.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method prevDayOfWeek [line 587]

string prevDayOfWeek( int $dow, [string $day = ""], [string $month = ""], [string $year = ""], [boolean $format = "%Y%m%d"], [string $onOrBefore = false])

Returns date of the previous specific day of the week from the given date.



Tags:

return:  date in given format
access:  public


Parameters:

int   $dow   day of week, 0=Sunday
string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
boolean   $format   onOrBefore if true and days are same, returns current day
string   $onOrBefore   format for returned date

[ Top ]

method prevDayOfWeekOnOrBefore [line 648]

string prevDayOfWeekOnOrBefore( int $dow, [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the previous specific day of the week on or before the given date.



Tags:

return:  date in given format
access:  public


Parameters:

int   $dow   day of week, 0=Sunday
string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method prevWeekday [line 507]

string prevWeekday( [string $day = ""], [string $month = ""], [string $year = ""], [string $format = "%Y%m%d"])

Returns date of the previous weekday, skipping from Monday to Friday.



Tags:

return:  date in given format
access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day
string   $format   format for returned date

[ Top ]

method quarterOfYear [line 289]

int quarterOfYear( [string $day = ""], [string $month = ""], [string $year = ""])

Returns quarter of the year for given date



Tags:

access:  public


Parameters:

string   $day   year in format CCYY, default current local year
string   $month   month in format MM, default current local month
string   $year   day in format DD, default current local day

[ Top ]

method weekOfYear [line 225]

integer weekOfYear( string $day, string $month, string $year)

Returns week of the year, first Sunday is first day of first week



Tags:

access:  public


Parameters:

string   $day   day in format DD
string   $month   month in format MM
string   $year   year in format CCYY

[ Top ]

method weeksInMonth [line 804]

int weeksInMonth( [string $month = ""], [string $year = ""])

Returns the number of rows on a calendar month. Useful for determining the number of rows when displaying a typical month calendar.



Tags:

return:  number of weeks
access:  public


Parameters:

string   $month   month in format MM, default current local month
string   $year   year in format YYCC, default current local year

[ Top ]


Documentation generated on Tue, 29 Mar 2005 09:03:37 -0800 by phpDocumentor 1.2.0rc2