AnewtDateTime Class Reference

This class provides methods for date and time operations. More...

List of all members.

Public Member Functions

 __construct ()
 Constructor (triggers an error).

Static Public Member Functions

Construction and parsing methods
These methods can be used to obtain an AnewtDateTimeAtom instance. There are multiple methods to parse dates in various formats.

static now ()
 Get the current date and time.
static parse ($date)
 Parses a date into a AnewtDateTimeAtom instance.
static parse_timestamp ($timestamp)
 Converts a timestamp into a AnewtDateTimeAtom instance.
static parse_string ($date)
 Parses a date string and returns a AnewtDateTimeAtom instance.
static parse_ymd ($year, $month=1, $day=1)
 Parse year, month and day integers and return a AnewtDateTimeAtom instance.
Validating and checking methods
static is_valid_date_ymd ($year, $month, $day)
 Check if a date (without time) is valid.
static is_valid_time_hms ($hour, $minute, $second)
 Check if a time (without date) is valid.
static is_valid ($date)
 Checks if a given date is valid.
static is_current_year ($date)
 Checks if a date is in the current year.
static is_today ($date)
 Checks if a date is the same date as today.
Formatting methods
static year ($date)
 Get the year.
static month ($date)
 Get the month.
static day ($date)
 Get the day.
static hour ($date)
 Get the hours.
static minute ($date)
 Get the minutes.
static second ($date)
 Get the seconds.
static timestamp ($date)
 Get a timestamp.
static format ($format, $date)
 Formats a date in strftime()-like format.
static date ($date)
 Get the date only.
static time ($date)
 Get the time only.
static week ($date)
 Get the week number.
static day_of_year ($date)
 Get the day number in the year.
static iso8601 ($date)
 Format the date in standard ISO 8601 format.
static iso8601_compact ($date)
 Format the date in compact ISO 8601 format.
static iso8601_date_compact ($date)
 Format the date in compact ISO 8601 date format.
static iso8601_time_compact ($date)
 Format the date in compact ISO 8601 time format.
static iso8601_week ($date)
 Format the date in ISO 8601 week format.
static iso8601_week_day ($date)
 Format the date in ISO 8601 week and day format.
static iso8601_day_of_year ($date)
 Format the date in ISO 8601 year-day format.
static rfc2822 ($date)
 Format the date in RFC 2922 format.
static sql ($date)
 Format the date in SQL92 DATETIME format.
static sql_date ($date)
 Format the date in SQL92 DATE format.
static sql_time ($date)
 Format the date in SQL92 TIME format.
static beat ($date)
 Get the swatch internet time beats.
static format_if_current_year ($format_if_current_year, $format_if_not_current_year, $date)
 Formats a date, using an alternative format if the given date is in the current year.
static format_if_today ($format_if_today, $format_if_not_today, $date)
 Formats a date, using an alternative format if the given date is the same day as today.


Detailed Description

This class provides methods for date and time operations.

It supports both parsing and formatting.

Definition at line 126 of file datetime.lib.php.


Constructor & Destructor Documentation

AnewtDateTime::__construct (  ) 

Constructor (triggers an error).

This class provides only static methods.

Definition at line 131 of file datetime.lib.php.


Member Function Documentation

static AnewtDateTime::now (  )  [static]

Get the current date and time.

Returns:
AnewtDateTimeAtom representing the current date.

Definition at line 151 of file datetime.lib.php.

static AnewtDateTime::parse ( date  )  [static]

Parses a date into a AnewtDateTimeAtom instance.

The function also accepts AnewtDateTimeAtom instances. In that case the supplied instance is returned. If parsing fails, null is returned.

Note that in many cases you should just call one of the more specific parsing methods instead.

Parameters:
$date An int/string/AnewtDateTimeAtom which will be parsed.
Returns:
A newly created AnewtDateTimeAtom instance or null if parsing failed.
See also:
AnewtDateTime::parse_timestamp

AnewtDateTime::parse_string

AnewtDateTime::parse_ymd

Definition at line 174 of file datetime.lib.php.

static AnewtDateTime::parse_timestamp ( timestamp  )  [static]

Converts a timestamp into a AnewtDateTimeAtom instance.

Parameters:
$timestamp Timestamp to use.
Returns:
A newly created AnewtDateTimeAtom instance or null if parsing failed.

Definition at line 201 of file datetime.lib.php.

static AnewtDateTime::parse_string ( date  )  [static]

Parses a date string and returns a AnewtDateTimeAtom instance.

This method supports many common date and time formats, including SQL's DATETIME and several ISO 8601 forms.

Parameters:
$date A string specifying a date.
Returns:
A newly created AnewtDateTimeAtom instance or null if parsing failed.

Definition at line 221 of file datetime.lib.php.

static AnewtDateTime::parse_ymd ( year,
month = 1,
day = 1 
) [static]

Parse year, month and day integers and return a AnewtDateTimeAtom instance.

This method is useful if you want to transform year, month and day values into an AnewtDateTimeAtom instance.

Parameters:
$year The year (integer)
$month The month (integer, defaults to 1 if omitted)
$day The day (integer, defaults to 1 if omitted)
Returns:
A newly created AnewtDateTimeAtom instance or null if parsing failed.

Definition at line 418 of file datetime.lib.php.

static AnewtDateTime::is_valid_date_ymd ( year,
month,
day 
) [static]

Check if a date (without time) is valid.

Parameters:
$year Year
$month Month
$day Day
Returns:
True if this is a valid date, false otherwise.

Definition at line 450 of file datetime.lib.php.

static AnewtDateTime::is_valid_time_hms ( hour,
minute,
second 
) [static]

Check if a time (without date) is valid.

Parameters:
$hour Hour
$minute Minute
$second Second
Returns:
True if this is a valid time, false otherwise.

Definition at line 468 of file datetime.lib.php.

static AnewtDateTime::is_valid ( date  )  [static]

Checks if a given date is valid.

Parameters:
$date Any date-like object; this could be a string, timestamp or a AnewtDateTimeAtom instance.
Returns:
True if this is a valid date, false otherwise.

Definition at line 485 of file datetime.lib.php.

static AnewtDateTime::is_current_year ( date  )  [static]

Checks if a date is in the current year.

Parameters:
$date A date-like object.
Returns:
True if the given date is in the current year, false otherwise.

Definition at line 510 of file datetime.lib.php.

static AnewtDateTime::is_today ( date  )  [static]

Checks if a date is the same date as today.

Parameters:
$date A date-like object.
Returns:
True if the date is today, false otherwise.

Definition at line 524 of file datetime.lib.php.

static AnewtDateTime::year ( date  )  [static]

Get the year.

Parameters:
$date A date-like object (optional).
Returns:
The year of the given date.

Definition at line 547 of file datetime.lib.php.

static AnewtDateTime::month ( date  )  [static]

Get the month.

Parameters:
$date A date-like object (optional).
Returns:
The month of the given date.

Definition at line 566 of file datetime.lib.php.

static AnewtDateTime::day ( date  )  [static]

Get the day.

Parameters:
$date A date-like object (optional).
Returns:
The day of the given date.

Definition at line 585 of file datetime.lib.php.

static AnewtDateTime::hour ( date  )  [static]

Get the hours.

Parameters:
$date A date-like object (optional).
Returns:
The hours of the given date.

Definition at line 604 of file datetime.lib.php.

static AnewtDateTime::minute ( date  )  [static]

Get the minutes.

Parameters:
$date A date-like object (optional).
Returns:
The minutes of the given date.

Definition at line 623 of file datetime.lib.php.

static AnewtDateTime::second ( date  )  [static]

Get the seconds.

Parameters:
$date A date-like object (optional).
Returns:
The seconds of the given date.

Definition at line 642 of file datetime.lib.php.

static AnewtDateTime::timestamp ( date  )  [static]

Get a timestamp.

Parameters:
$date A date-like object (optional).
Returns:
A timestamp representing the given date.

Definition at line 661 of file datetime.lib.php.

static AnewtDateTime::format ( format,
date 
) [static]

Formats a date in strftime()-like format.

Parameters:
$format A format specifier in strftime() syntax.
$date A date-like object (optional).
Returns:
A formatted date representation.

Definition at line 682 of file datetime.lib.php.

static AnewtDateTime::date ( date  )  [static]

Get the date only.

Example: 1983-01-15.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-mm-dd format.

Definition at line 702 of file datetime.lib.php.

static AnewtDateTime::time ( date  )  [static]

Get the time only.

Example: 18:30:00.

Parameters:
$date A date-like object (optional).
Returns:
A string in hh:mm:ss format.

Definition at line 721 of file datetime.lib.php.

static AnewtDateTime::week ( date  )  [static]

Get the week number.

Example: 1983-W02.

Parameters:
$date A date-like object (optional).
Returns:
An integer denoting the week number of this year.

Definition at line 740 of file datetime.lib.php.

static AnewtDateTime::day_of_year ( date  )  [static]

Get the day number in the year.

Example: 15.

Parameters:
$date A date-like object (optional).
Returns:
An integer denoting the day number of this year.

Definition at line 759 of file datetime.lib.php.

static AnewtDateTime::iso8601 ( date  )  [static]

Format the date in standard ISO 8601 format.

Example: 1983-01-15T18:30:00.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-mm-ddThh:mm:ss format.

Definition at line 779 of file datetime.lib.php.

static AnewtDateTime::iso8601_compact ( date  )  [static]

Format the date in compact ISO 8601 format.

Example: 19830115T183000.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyymmddThhmmss format.

Definition at line 798 of file datetime.lib.php.

static AnewtDateTime::iso8601_date_compact ( date  )  [static]

Format the date in compact ISO 8601 date format.

Example: 19830115.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyymmdd format.

Definition at line 817 of file datetime.lib.php.

static AnewtDateTime::iso8601_time_compact ( date  )  [static]

Format the date in compact ISO 8601 time format.

Example: 183000.

Parameters:
$date A date-like object (optional).
Returns:
A string in hhmmss format.

Definition at line 836 of file datetime.lib.php.

static AnewtDateTime::iso8601_week ( date  )  [static]

Format the date in ISO 8601 week format.

Example: 1983-W02.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-Wnn format.

Definition at line 855 of file datetime.lib.php.

static AnewtDateTime::iso8601_week_day ( date  )  [static]

Format the date in ISO 8601 week and day format.

Example: 1983-W02-6.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-Wnn-m format.

Definition at line 874 of file datetime.lib.php.

static AnewtDateTime::iso8601_day_of_year ( date  )  [static]

Format the date in ISO 8601 year-day format.

Example: 1983-015.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-nnn format.

Definition at line 893 of file datetime.lib.php.

static AnewtDateTime::rfc2822 ( date  )  [static]

Format the date in RFC 2922 format.

Example: Sat, 15 Jan 1983 18:30:00 +0100. This format can be used for e-mail messages or RSS 2 feeds.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-nnn format.

Definition at line 913 of file datetime.lib.php.

static AnewtDateTime::sql ( date  )  [static]

Format the date in SQL92 DATETIME format.

Example: 1983-01-15 18:30:00. This format can be used in SQL queries.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-mm-dd hh:mm:ss format.
See also:
AnewtDateTime::sql_date

AnewtDateTime::sql_time

Definition at line 936 of file datetime.lib.php.

static AnewtDateTime::sql_date ( date  )  [static]

Format the date in SQL92 DATE format.

Example: 1983-01-15. This format can be used in SQL queries.

Parameters:
$date A date-like object (optional).
Returns:
A string in yyyy-mm-dd format.
See also:
AnewtDateTime::sql

AnewtDateTime::sql_time

Definition at line 959 of file datetime.lib.php.

static AnewtDateTime::sql_time ( date  )  [static]

Format the date in SQL92 TIME format.

Example: 18:30:00. This format can be used in SQL queries.

Parameters:
$date A date-like object (optional).
Returns:
A string in hh:mm:ss format.
See also:
AnewtDateTime::sql

AnewtDateTime::sql_date

Definition at line 982 of file datetime.lib.php.

static AnewtDateTime::beat ( date  )  [static]

Get the swatch internet time beats.

Parameters:
$date A date-like object (optional).
Returns:
A string in @000 format.

Definition at line 1001 of file datetime.lib.php.

static AnewtDateTime::format_if_current_year ( format_if_current_year,
format_if_not_current_year,
date 
) [static]

Formats a date, using an alternative format if the given date is in the current year.

Parameters:
$format_if_current_year A format specifier in strftime() syntax, used if the date is in the current year.
$format_if_not_current_year A format specifier in strftime() syntax, used if the date is not in the current year.
$date A date-like object (optional).
Returns:
A formatted date representation.
See also:
AnewtDateTime::format

AnewtDateTime::format_if_today

Definition at line 1030 of file datetime.lib.php.

static AnewtDateTime::format_if_today ( format_if_today,
format_if_not_today,
date 
) [static]

Formats a date, using an alternative format if the given date is the same day as today.

Parameters:
$format_if_today A format specifier in strftime() syntax, used if the date is today.
$format_if_not_today A format specifier in strftime() syntax, used if the date is not today.
$date A date-like object (optional).
Returns:
A formatted date representation.
See also:
AnewtDateTime::format

AnewtDateTime::format_if_current_year

Definition at line 1062 of file datetime.lib.php.


The documentation for this class was generated from the following file:

Generated on Sun Aug 2 22:54:37 2009 for Anewt by  doxygen 1.5.9