[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Pear/Date/ -> Calc.php (sommaire)

(pas de description)

Poids: 1736 lignes (53 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Date_Calc:: (51 méthodes):
  dateNow()
  isValidDate()
  isLeapYear()
  isFutureDate()
  isPastDate()
  dayOfWeek()
  weekOfYear()
  julianDate()
  quarterOfYear()
  beginOfNextMonth()
  endOfNextMonth()
  beginOfPrevMonth()
  endOfPrevMonth()
  nextWeekday()
  prevWeekday()
  nextDayOfWeek()
  prevDayOfWeek()
  nextDayOfWeekOnOrAfter()
  prevDayOfWeekOnOrBefore()
  nextDay()
  prevDay()
  defaultCentury()
  dateDiff()
  compareDates()
  daysInMonth()
  weeksInMonth()
  firstOfMonthWeekday()
  beginOfMonth()
  beginOfWeek()
  endOfWeek()
  beginOfNextWeek()
  beginOfPrevWeek()
  getCalendarWeek()
  getCalendarMonth()
  getCalendarYear()
  dateToDays()
  daysToDate()
  NWeekdayOfMonth()
  dateFormat()
  getYear()
  getMonth()
  getDay()
  getMonthFullname()
  getMonthAbbrname()
  getWeekdayFullname()
  getWeekdayAbbrname()
  getMonthFromFullName()
  getMonthNames()
  getWeekDays()
  gregorianToISO()
  dateSeason()


Classe: Date_Calc  - X-Ref

Date_Calc is a calendar class used to calculate and
manipulate calendar dates and retrieve dates in a calendar
format. It does not rely on 32-bit system date stamps, so
you can display calendars and compare dates that date
pre 1970 and post 2038.

This source file is subject to version 2.02 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available at through the world-wide-web at
http://www.php.net/license/2_02.txt.
If you did not receive a copy of the PHP license and are unable to
obtain it through the world-wide-web, please send a note to
license@php.net so we can mail you a copy immediately.

Copyright (c) 1999, 2002, 2003 ispi

dateNow($format='%Y%m%d')   X-Ref
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.

param: string the strftime() format to return the date
return: string the current date in specified format

isValidDate($day, $month, $year)   X-Ref
Returns true for valid date, false for invalid date.

param: string year in format CCYY
param: string month in format MM
param: string day in format DD
return: boolean true/false

isLeapYear($year='')   X-Ref
Returns true for a leap year, else false

param: string year in format CCYY
return: boolean true/false

isFutureDate($day,$month,$year)   X-Ref
Determines if given date is a future date from now.

param: string day in format DD
param: string month in format MM
param: string year in format CCYY
return: boolean true/false

isPastDate($day,$month,$year)   X-Ref
Determines if given date is a past date from now.

param: string day in format DD
param: string month in format MM
param: string year in format CCYY
return: boolean true/false

dayOfWeek($day='',$month='',$year='')   X-Ref
Returns day of week for given date, 0=Sunday

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int $weekday_number

weekOfYear($day='',$month='',$year='')   X-Ref
Returns week of the year, first Sunday is first day of first week

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: integer $week_number

julianDate($day='',$month='',$year='')   X-Ref
Returns number of days since 31 December of year before given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int $julian

quarterOfYear($day='',$month='',$year='')   X-Ref
Returns quarter of the year for given date

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int $year_quarter

beginOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of begin of next month of given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

endOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the last day of next month of given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

beginOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the first day of previous month of given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

endOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the last day of previous month for given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

nextWeekday($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the next weekday of given date,
skipping from Friday to Monday.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

prevWeekday($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the previous weekday,
skipping from Monday to Friday.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

nextDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrAfter=false)   X-Ref
Returns date of the next specific day of the week
from the given date.

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

prevDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrBefore=false)   X-Ref
Returns date of the previous specific day of the week
from the given date.

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

nextDayOfWeekOnOrAfter($dow,$day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the next specific day of the week
on or after the given date.

param: int day of week, 0=Sunday
param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

prevDayOfWeekOnOrBefore($dow,$day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of the previous specific day of the week
on or before the given date.

param: int day of week, 0=Sunday
param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

nextDay($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of day after given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

prevDay($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Returns date of day before given date.

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

defaultCentury($year)   X-Ref
Sets century for 2 digit year.
51-99 is 19, else 20

param: string 2 digit year
return: string 4 digit year

dateDiff($day1,$month1,$year1,$day2,$month2,$year2)   X-Ref
Returns number of days between two given dates.

param: string $day1   day in format DD
param: string $month1 month in format MM
param: string $year1  year in format CCYY
param: string $day2   day in format DD
param: string $month2 month in format MM
param: string $year2  year in format CCYY
return: int absolute number of days between dates,

compareDates($day1,$month1,$year1,$day2,$month2,$year2)   X-Ref
Compares two dates

param: string $day1   day in format DD
param: string $month1 month in format MM
param: string $year1  year in format CCYY
param: string $day2   day in format DD
param: string $month2 month in format MM
param: string $year2  year in format CCYY
return: int 0 on equality, 1 if date 1 is greater, -1 if smaller

daysInMonth($month='',$year='')   X-Ref
Find the number of days in the given month.

param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int number of days

weeksInMonth($month='',$year='')   X-Ref
Returns the number of rows on a calendar month. Useful for
determining the number of rows when displaying a typical
month calendar.

param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int number of weeks

firstOfMonthWeekday($month='',$year='')   X-Ref
Find the day of the week for the first of the month of given date.

param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: int number of weekday for the first day, 0=Sunday

beginOfMonth($month='',$year='',$format='%Y%m%d')   X-Ref
Return date of first day of month of given date.

param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

beginOfWeek($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Find the month day of the beginning of week for given date,
using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

endOfWeek($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Find the month day of the end of week for given date,
using DATE_CALC_BEGIN_WEEKDAY. (can return weekday
of following month.)

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

beginOfNextWeek($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Find the month day of the beginning of week after given date,
using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

beginOfPrevWeek($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Find the month day of the beginning of week before given date,
using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: string date in given format

getCalendarWeek($day='',$month='',$year='',$format='%Y%m%d')   X-Ref
Return an array with days in week

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: array $week[$weekday]

getCalendarMonth($month='',$year='',$format='%Y%m%d')   X-Ref
Return a set of arrays to construct a calendar month for
the given date.

param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: string format for returned date
return: array $month[$row][$col]

getCalendarYear($year='',$format='%Y%m%d')   X-Ref
Return a set of arrays to construct a calendar year for
the given date.

param: string year in format CCYY, default current local year
param: string format for returned date
return: array $year[$month][$row][$col]

dateToDays($day,$month,$year)   X-Ref
Converts a date to number of days since a
distant unspecified epoch.

param: string day in format DD
param: string month in format MM
param: string year in format CCYY
return: integer number of days

daysToDate($days,$format='%Y%m%d')   X-Ref
Converts number of days to a distant unspecified epoch.

param: int number of days
param: string format for returned date
return: string date in specified format

NWeekdayOfMonth($occurance,$dayOfWeek,$month,$year,$format='%Y%m%d')   X-Ref
Calculates the date of the Nth weekday of the month,
such as the second Saturday of January 2000.

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

dateFormat($day,$month,$year,$format)   X-Ref
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 '%'

param: string day in format DD
param: string month in format MM
param: string year in format CCYY
param: string format for returned date
return: string date in given format

getYear()   X-Ref
Returns the current local year in format CCYY

return: string year in format CCYY

getMonth()   X-Ref
Returns the current local month in format MM

return: string month in format MM

getDay()   X-Ref
Returns the current local day in format DD

return: string day in format DD

getMonthFullname($month)   X-Ref
Returns the full month name for the given month

param: string month in format MM
return: string full month name

getMonthAbbrname($month,$length=3)   X-Ref
Returns the abbreviated month name for the given month

param: string month in format MM
param: int optional length of abbreviation, default is 3
return: string abbreviated month name

getWeekdayFullname($day='',$month='',$year='')   X-Ref
Returns the full weekday name for the given date

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
return: string full month name

getWeekdayAbbrname($day='',$month='',$year='',$length=3)   X-Ref
Returns the abbreviated weekday name for the given date

param: string day in format DD, default is current local day
param: string month in format MM, default is current local month
param: string year in format CCYY, default is current local year
param: int optional length of abbreviation, default is 3
return: string full month name

getMonthFromFullName($month)   X-Ref
Returns the numeric month from the month name or an abreviation

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

param: string  month name
return: integer month number

getMonthNames()   X-Ref
Returns 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.

returns: array An array of month names

getWeekDays()   X-Ref
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.

returns: array An array of week day names

gregorianToISO($day,$month,$year)   X-Ref
Converts from Gregorian Year-Month-Day to
ISO YearNumber-WeekNumber-WeekDay

Uses ISO 8601 definitions.
Algorithm from Rick McCarty, 1999 at
http://personal.ecu.edu/mccartyr/ISOwdALG.txt

param: string day in format DD
param: string month in format MM
param: string year in format CCYY
return: string

dateSeason($season, $year = '')   X-Ref
Determines julian date of the given season
Adapted from previous work in Java by James Mark Hamilton, mhamilton@qwest.net

author: Robert Butler <rob@maxwellcreek.org>
param: string is VERNALEQUINOX, SUMMERSOLSTICE, AUTUMNALEQUINOX, or WINTERSOLSTICE.
param: string year in format CCYY, must be a calendar year between -1000BC and 3000AD.
return: float $juliandate



Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7