## P4A_Date

Description

Date/Time Class.

Library for standard date operations like formatting/unformatting.
Some parts of the code are based on PEAR::Date and PEAR::Date_Calc packages at {link http://pear.php.net/package-info.php?package=Date}, modified for p4a necessity.

- author: Andrea Giardina <andrea.giardina@crealabs.it>
- author: Fabrizio Balliano <fabrizio.balliano@crealabs.it>

Located in /p4a/libraries/date.php (line 48)

Method Summary
integer date_to_days ([string $year = NULL], [string $month = NULL], [string $day = NULL])
string days_to_date (int $days, [string $format = '%Y%m%d'], [array $locale_vars = NULL])
int day_of_week ([string $year = NULL], [string $month = NULL], [string $day = NULL])
string format ([string $date = NULL], string $format, [array $locale_vars = NULL])
array get_months_names ()
string get_month_name ([string $month = NULL], [array $locale_vars = NULL])
string get_month_short_name ([string $month = NULL], [array $locale_vars = NULL])
array get_weekdays_names ()
string get_weekday_name ([string $year = NULL], [string $month = NULL], [string $day = NULL], [array $locale_vars = NULL])
string get_weekday_short_name ([string $year = NULL], [string $month = NULL], [string $day = NULL], [array $locale_vars = NULL])
string gregorian_to_iso (string $year, string $month, string $day)
boolean is_future_date (string $year, string $month, string $day)
boolean is_leap_year ([string $year = NULL])
boolean is_past_date (string $year, string $month, string $day)
boolean is_valid_date (string $year, string $month, string $day)
int julian_date ([string $year = NULL], [string $month = NULL], [string $day = NULL])
string now ([string $format = '%Y%m%d'])
array parse (string $date)
string unformat (string $date, string $format, [string $output_format = P4A_DATETIME], [array $locale_vars = NULL])
integer week_of_year ([string $year = NULL], [string $month = NULL], [string $day = NULL])
Methods
date_to_days (line 671)

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

- return: number of days
- access: public

integer date_to_days ([string $year = NULL], [string $month = NULL], [string $day = NULL])

- string $year: year in format YYYY
- string $month: month in format MM
- string $day: day in format DD

days_to_date (line 712)

Converts number of days to a distant unspecified epoch.

- return: date in specified format
- access: public

string days_to_date (int $days, [string $format = '%Y%m%d'], [array $locale_vars = NULL])

- int $days: number of days
- string $format: format for returned date
- array $locale_vars: localization strings for months names

day_of_week (line 555)

Returns day of week for given date, 0=Sunday

- access: public

int day_of_week ([string $year = NULL], [string $month = NULL], [string $day = NULL])

- string $year: year in format YYYY, default is current local year
- string $month: month in format MM, default is current local month
- string $day: day in format DD, default is current local day

format (line 95)

Date pretty printing, similar to strftime()

Formats the date in the given format, much like strftime(). Most strftime() options are supported.

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)
%C century number (the year divided by 100 and truncated to an integer, range 00 to 99)
%d day of month (range 01 to 31)
%D same as "%m/%d/%y"
%e day of month, single digit (range 0 to 31)
%E number of days since unspecified epoch (integer, Date_Calc::dateToDays())
%H hour as decimal number (00 to 23)
%I hour as decimal number on 12-hour clock (01 to 12)
%j day of year (range 001 to 366)
%m month as decimal number (range 01 to 12)
%M minute as a decimal number (00 to 59)
%n newline character (\n)
%O dst-corrected timezone offset expressed as "+/-HH:MM"
%o raw timezone offset expressed as "+/-HH:MM"
%p either 'am' or 'pm' depending on the time
%P either 'AM' or 'PM' depending on the time
%r time in am/pm notation, same as "%I:%M:%S %p"
%R time in 24-hour notation, same as "%H:%M"
%S seconds as a decimal number (00 to 59)
%t tab character (\t)
%T current time, same as "%H:%M:%S"
%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 '%'

- return: date/time in given format
- access: public

string format ([string $date = NULL], string $format, [array $locale_vars = NULL])

- string $date: date in standard date/time format
- string $format: the desidered formatting format
- array $locale_vars: localization strings

get_months_names (line 653)

Returns an array of month names Used to take advantage of the setlocale function to return language specific month names.

- return: An array of month names

array get_months_names ()
get_month_name (line 619)

Returns the full month name for the given month

- return: full month name
- access: public

string get_month_name ([string $month = NULL], [array $locale_vars = NULL])

- string $month: month in format MM
- array $locale_vars: localization strings for months names

get_month_short_name (line 642)

Returns the abbreviated month name for the given month

- return: abbreviated month name
- see: P4A_Date::get_month_name
- access: public

string get_month_short_name ([string $month = NULL], [array $locale_vars = NULL])

- string $month: month in format MM
- array $locale_vars: localization strings for months names

get_weekdays_names (line 604)

Returns an array of week days

Used to take advantage of the setlocale function to return language specific week days

- return: An array of week day names
- access: public

array get_weekdays_names ()
get_weekday_name (line 536)

Returns the full weekday name for the given date

- return: full month name
- see: P4A_Date::get_weekday_name
- access: public

string get_weekday_name ([string $year = NULL], [string $month = NULL], [string $day = NULL], [array $locale_vars = NULL])

- string $year: year in format YYYY, default is current local year
- string $month: month in format MM, default is current local month
- string $day: day in format DD, default is current local day
- array $locale_vars: localization strings for days names

get_weekday_short_name (line 521)

Returns the abbreviated weekday name for the given date

- return: full month name
- see: P4A_Date::get_weekday_name
- access: public

string get_weekday_short_name ([string $year = NULL], [string $month = NULL], [string $day = NULL], [array $locale_vars = NULL])

- string $year: year in format YYYY, default is current local year
- string $month: month in format MM, default is current local month
- string $day: day in format DD, default is current local day
- array $locale_vars: localization strings for days names

gregorian_to_iso (line 831)

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. Transcribed to PHP by Jesus M. Castagnetto

- access: public

string gregorian_to_iso (string $year, string $month, string $day)

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

is_future_date (line 908)

Determines if given date is a future date from now.

- access: public

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

- string $year: year in format YYYY
- string $month: month in format MM
- string $day: day in format DD

is_leap_year (line 785)

Returns true for a leap year, else false

- access: public

boolean is_leap_year ([string $year = NULL])

- string $year: year in format YYYY

is_past_date (line 937)

Determines if given date is a past date from now.

- access: public

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

- string $year: year in format YYYY
- string $month: month in format MM
- string $day: day in format DD

is_valid_date (line 498)

Returns true for valid date, false for invalid date.

- access: public

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

- string $year: year in format YYYY
- string $month: month in format MM
- string $day: day in format DD

julian_date (line 751)

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

- access: public

int julian_date ([string $year = NULL], [string $month = NULL], [string $day = NULL])

- string $year: year in format YYYY, default is current local year
- string $month: month in format MM, default is current local month
- string $day: day in format DD, default is current local day

now (line 592)

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.

- return: the current date in specified format
- access: public

string now ([string $format = '%Y%m%d'])

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

parse (line 441)

Parses a date in the standard datetime format and returns an associative array with every single date part.

- access: public

array parse (string $date)

- string $date: the date

unformat (line 243)

Reverse date analysis on a formatted date.

This function takes the formatted date and the original format and try to get it back in standard datetime format.

- access: public

string unformat (string $date, string $format, [string $output_format = P4A_DATETIME], [array $locale_vars = NULL])

- string $date: formatted date
- string $format: the format
- string $output_format: the output format
- array $locale_vars: localization strings

week_of_year (line 810)

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

- access: public

integer week_of_year ([string $year = NULL], [string $month = NULL], [string $day = NULL])

- string $year: year in format YYYY, default is current local year
- string $month: month in format MM, default is current local month
- string $day: day in format DD, default is current local day

Documentation generated on Fri, 26 May 2006 12:43:06 +0200 by phpDocumentor 1.3.0RC5