[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/date/date_php4/ -> date_php4_calc.inc (summary)

Calculates and manipulates dates with no reliance on 32-bit system timestamps, to work on dates before 1970 and after 2038. This file must be included whenever these functions are used, it is not automatically available.

File Size: 1498 lines (41 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 41 functions

  date_calc_format()
  date_calc_is_valid()
  date_calc_date_to_days()
  date_calc_days_to_date()
  date_calc_gregorian_to_ISO()
  date_calc_date_season()
  date_calc_date_now()
  date_calc_get_year()
  date_calc_get_month()
  date_calc_get_day()
  date_calc_julian_date()
  date_calc_get_weekday_fullname()
  date_calc_get_weekday_abbrname()
  date_calc_get_month_fullname()
  date_calc_get_month_abbrname()
  date_calc_get_month_from_fullname()
  date_calc_week_of_year()
  date_calc_quarter_of_year()
  date_calc_days_in_month()
  date_calc_weeks_in_month()
  date_calc_get_calendar_week()
  date_calc_get_calendar_month()
  date_calc_get_calendar_year()
  date_calc_prev_day()
  date_calc_next_day()
  date_calc_prev_weekday()
  date_calc_next_weekday()
  date_calc_prev_day_of_week()
  date_calc_next_day_of_week()
  date_calc_begin_of_week()
  date_calc_end_of_week()
  date_calc_begin_of_prev_week()
  date_calc_begin_of_next_week()
  date_calc_begin_of_month_by_span()
  date_calc_end_of_month_by_span()
  date_calc_first_of_month_weekday()
  date_calc_n_weekday_of_month()
  date_calc_is_future_date()
  date_calc_is_past_date()
  date_calc_date_diff()
  date_calc_compare_dates()

Functions
Functions that are not part of a class:

date_calc_format($day, $month, $year, $format = DATE_CALC_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:
<pre>
%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
date_calc_days_to_date() 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 '%'
</pre>

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_is_valid($day, $month, $year)   X-Ref
Returns true for valid date, false for invalid date.
Renamed this function because we already have a similar function that
expects a full date as a parameter.

param: int  $day
param: int  $month
param: int  $year
return: boolean

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

param: int  $day
param: int  $month
param: int  $year
return: integer

date_calc_days_to_date($days, $format = DATE_CALC_FORMAT)   X-Ref
Converts number of days to a distant unspecified epoch

param: int  $days
param: string $format
return: string

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

Uses ISO 8601 definitions.  Algorithm by Rick McCarty, 1999 at
http://personal.ecu.edu/mccartyr/ISOwdALG.txt .
Transcribed to PHP by Jesus M. Castagnetto.

param: int  $day
param: int  $month
param: int  $year
return: string

date_calc_date_season($season, $year = 0)   X-Ref
Determines julian date of the given season

Adapted from previous work in Java by James Mark Hamilton.

author: James Mark Hamilton <mhamilton@qwest.net>
author: Robert Butler <rob@maxwellcreek.org>
param: string $season
param: string $year
return: float

date_calc_date_now($format = DATE_CALC_FORMAT)   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 $format
return: string

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

param: int $days
return: string

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

param: int $days
return: string

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

param: int $days
return: string

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

param: int  $day
param: int  $month
param: int  $year
return: int

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

param: int  $day
param: int  $month
param: int  $year
return: string

date_calc_get_weekday_abbrname($day = 0, $month = 0, $year = 0)   X-Ref
Returns the abbreviated weekday name for the given date.

param: int  $day
param: int  $month
param: int  $year
param: int  $length
return: string

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

param: int  $month
return: string

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

param: int  $month
param: int  $length
return: string

date_calc_get_month_from_fullname($month)   X-Ref
Returns the numeric month from the month name or an abreviation
Both August and Aug would return 8.

param: string $month
return: integer

date_calc_week_of_year($day = 0, $month = 0, $year = 0)   X-Ref
Returns week of the year, first Sunday is first day of first week.

param: int  $day
param: int  $month
param: int  $year
return: int

date_calc_quarter_of_year($day = 0, $month = 0, $year = 0)   X-Ref
Returns quarter of the year for given date.

param: int  $day
param: int  $month
param: int  $year
return: int

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

param: int  $month
param: int  $year
return: int

date_calc_weeks_in_month($month = 0, $year = 0)   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: int  $month
param: int  $year
return: int

date_calc_get_calendar_week($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Return an array with days in week.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: array

date_calc_get_calendar_month($month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Return a set of arrays to construct a calendar month for the given date.

param: int  $month
param: int  $year
param: string $format
return: array

date_calc_get_calendar_year($year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Return a set of arrays to construct a calendar year for the given date

param: int  $year
param: string $format
return: array $year[$month][$row][$col]

date_calc_prev_day($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of day before given date.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_next_day($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of day after given date

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_prev_weekday($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of the previous weekday, skipping from Monday to Friday

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_next_weekday($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of the next weekday of given date, skipping from
Friday to Monday.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_prev_day_of_week($dow, $day = 0, $month = 0, $year = 0,$format = DATE_CALC_FORMAT, $on_or_before = false)   X-Ref
Returns date of the previous specific day of the week
from the given date.

param: int
param: int  $day
param: int  $month
param: int  $year
param: bool   $on_or_before
param: string $format
return: string

date_calc_next_day_of_week($dow, $day = 0, $month = 0, $year = 0,$format = DATE_CALC_FORMAT, $on_or_after = false)   X-Ref
Returns date of the next specific day of the week
from the given date.

param: int  $dow
param: int  $day
param: int  $month
param: int  $year
param: bool   $on_or_after
param: string $format
return: string  the date in the desired format

date_calc_begin_of_week($day = 0, $month = 0, $year = 0,$format = DATE_CALC_FORMAT)   X-Ref
Find the month day of the beginning of week for given date,
using variable_get('date_first_day', 1). Can return weekday of prev month.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_end_of_week($day = 0, $month = 0, $year = 0,$format = DATE_CALC_FORMAT)   X-Ref
Find the month day of the end of week for given date, using
variable_get('date_first_day', 1). Can return weekday of following month.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_begin_of_prev_week($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Find the month day of the beginning of week before given date, using
variable_get('date_first_day', 1). Can return weekday of prev month.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_begin_of_next_week($day = 0, $month = 0, $year = 0,$format = DATE_CALC_FORMAT)   X-Ref
Find the month day of the beginning of week after given date, using
variable_get('date_first_day', 1). Can return weekday of next month.

param: int  $day
param: int  $month
param: int  $year
param: string $format
return: string  the date in the desired format

date_calc_begin_of_month_by_span($months = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of the first day of the month in the number of months
from the given date

param: int  $months
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_end_of_month_by_span($months = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT)   X-Ref
Returns date of the last day of the month in the number of months
from the given date.

param: int  $months
param: int  $month
param: int  $year
param: string $format
return: string

date_calc_first_of_month_weekday($month = 0, $year = 0)   X-Ref
Find the day of the week for the first of the month of given date

param: int  $month
param: int  $year
return: int

date_calc_n_weekday_of_month($week, $dow, $month, $year, $format = DATE_CALC_FORMAT)   X-Ref
Calculates the date of the Nth weekday of the month,
such as the second Saturday of January 2000

param: int  $week
param: int  $dow
param: int  $month
param: int  $year
param: string $format
return: string

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

param: int  $day
param: int  $month
param: int  $year
return: boolean

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

param: int  $day
param: int  $month
param: int  $year
return: boolean

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

param: int  $day1
param: int  $month1
param: int  $year1
param: int  $day2
param: int  $month2
param: int  $year2
return: int

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

param: int  $day1
param: int  $month1
param: int  $year1
param: int  $day2
param: int  $month2
param: int  $year2
return: int



Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7