Public Member Functions | Static Public Member Functions | Public Attributes

HabariDateTime Class Reference

List of all members.

Public Member Functions

 set_date ($year, $month, $day)
 set_isodate ($year, $week, $day=null)
 set_time ($hour, $minute, $second=null)
 set_timezone ($timezone)
 get_timezone ()
 format ($format=null)
 text_format ($format)
 modify ($args)
 get ($format=null)
 out ($format=null)
 __toString ()
 __get ($property)
 getdate ()
 friendly ($precision=7, $include_suffix=true)
 fuzzy ()

Static Public Member Functions

static __static ()
static set_default_datetime_format ($format)
static get_default_datetime_format ()
static set_default_timezone ($timezone)
static get_default_timezone ()
static date_create ($time=null, $timezone=null)
static get_default_date_format ()
static get_default_time_format ()
static difference ($start_date, $end_date)

Public Attributes

const YEAR = 31556926
const MONTH = 2629744
const WEEK = 604800
const DAY = 86400
const HOUR = 3600
const MINUTE = 60

Detailed Description

Definition at line 18 of file habaridatetime.php.


Member Function Documentation

HabariDateTime::__get ( property  ) 

Magic method to get magic ponies... properties, I mean.

Definition at line 295 of file habaridatetime.php.

static HabariDateTime::__static (  )  [static]

Set default timezone to system default on init.

Definition at line 38 of file habaridatetime.php.

HabariDateTime::__toString (  ) 

Magic method called when this object is cast to string. Returns the unix timestamp of this object.

Returns:
string The unix timestamp

Definition at line 287 of file habaridatetime.php.

static HabariDateTime::date_create ( time = null,
timezone = null 
) [static]
static HabariDateTime::difference ( start_date,
end_date 
) [static]

Returns an array representing the difference between two times by interval.

print_r( HabariDateTime::difference( 'now', 'January 1, 2010' ) ); // output (past): Array ( [invert] => [y] => 0 [m] => 9 [w] => 3 [d] => 5 [h] => 22 [i] => 33 [s] => 5 ) print_r( HabariDateTime::difference( 'now', 'January 1, 2011' ) ); // output (future): Array ( [invert] => 1 [y] => 0 [m] => 2 [w] => 0 [d] => 3 [h] => 5 [i] => 33 [s] => 11 )

If 'invert' is true, the time is in the future (ie: x from now). If it is false, the time is in the past (ie: x ago).

For more information, see PHP's DateInterval class, which this and friendly() attempt to emulate for < PHP 5.3

Todo:
Add total_days, total_years, etc. values?
Parameters:
mixed $start_date The start date, as a HDT object or any format accepted by HabariDateTime::date_create().
mixed $end_date The end date, as a HDT object or any format accepted by HabariDateTime::date_create().
Returns:
array Array of each interval and whether the interval is inverted or not.

Definition at line 495 of file habaridatetime.php.

Referenced by friendly().

HabariDateTime::format ( format = null  ) 

Returns date formatted according to given format.

See also:
DateTime::format()
Parameters:
string $format Format accepted by date().
Returns:
string The formatted date, false on failure.

Definition at line 216 of file habaridatetime.php.

Referenced by __get(), __toString(), get(), getdate(), and out().

HabariDateTime::friendly ( precision = 7,
include_suffix = true 
)

Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago

Parameters:
int $precision Only display x intervals. Note that this does not round, it only limits the display length.
boolean $include_suffix Include the 'ago' or 'from now' suffix?
Returns:
string Time passed in the specified units.

Definition at line 378 of file habaridatetime.php.

Referenced by __get().

HabariDateTime::fuzzy (  ) 

Similar to friendly(), but much more... fuzzy.

Returns a very short version of the difference in time between now and the current HDT object.

Definition at line 439 of file habaridatetime.php.

Referenced by __get().

HabariDateTime::get ( format = null  ) 
See also:
format()

Definition at line 265 of file habaridatetime.php.

Referenced by __static().

static HabariDateTime::get_default_date_format (  )  [static]

Return the default date format, as set in the Options table

Returns:
The default date format

Definition at line 342 of file habaridatetime.php.

static HabariDateTime::get_default_datetime_format (  )  [static]

Get the default date/time format set.

See also:
set_default_datetime_format()
Returns:
string The date format set.

Definition at line 74 of file habaridatetime.php.

static HabariDateTime::get_default_time_format (  )  [static]

Return the default time format, as set in the Options table

Returns:
The default time format

Definition at line 352 of file habaridatetime.php.

static HabariDateTime::get_default_timezone (  )  [static]

Get the timezone for Habari and PHP. Defaults to system timezone if not set.

See also:
set_default_timezone()
Parameters:
string The deafult timezone.

Definition at line 99 of file habaridatetime.php.

HabariDateTime::get_timezone (  ) 

Get the timezone identifier that is set for this datetime object.

Returns:
DateTimeZone The timezone object.

Definition at line 204 of file habaridatetime.php.

HabariDateTime::getdate (  ) 

Returns an associative array containing the date information for this HabariDateTime object, as per getdate()

Returns:
array Associative array containing the date information

Definition at line 363 of file habaridatetime.php.

Referenced by __get().

HabariDateTime::modify ( args  ) 

Alters the timestamp

Parameters:
string $format A format accepted by strtotime().
Returns:
HabariDateTime $this object.

Definition at line 256 of file habaridatetime.php.

HabariDateTime::out ( format = null  ) 

Echos date formatted according to given format.

See also:
format()
Parameters:
string $format Format accepted by date().

Definition at line 276 of file habaridatetime.php.

HabariDateTime::set_date ( year,
month,
day 
)

Set the date of this object

See also:
DateTime::setDate()
Parameters:
int $year Year of the date
int $month Month of the date
int $day Day of the date

Definition at line 148 of file habaridatetime.php.

static HabariDateTime::set_default_datetime_format ( format  )  [static]

Set default date/time format. The format is the same as the internal php date() function.

Parameters:
string $format The date format.

Definition at line 62 of file habaridatetime.php.

Referenced by __static().

static HabariDateTime::set_default_timezone ( timezone  )  [static]

Sets the timezone for Habari and PHP.

Parameters:
string $timezone A timezone name, not an abbreviation, for example 'America/New York'

Definition at line 85 of file habaridatetime.php.

Referenced by __static().

HabariDateTime::set_isodate ( year,
week,
day = null 
)

Sets the ISO date

See also:
DateTime::setISODate()
Parameters:
int $year Year of the date
int $month Month of the date
int $day Day of the date

Definition at line 162 of file habaridatetime.php.

HabariDateTime::set_time ( hour,
minute,
second = null 
)

Set the time of this object

See also:
DateTime::setTime()
Parameters:
int $hour Hour of the time
int $minute Minute of the time
int $second Second of the time

Definition at line 176 of file habaridatetime.php.

HabariDateTime::set_timezone ( timezone  ) 

Set the timezone for this datetime object. Can be either string timezone identifier, or DateTimeZone object.

See also:
DateTime::setTimezone()
Parameters:
mixed The timezone to use.
Returns:
HabariDateTime $this object.

Definition at line 190 of file habaridatetime.php.

HabariDateTime::text_format ( format  ) 

Returns date components inserted into a string

Example: echo HabariDateTime::date_create('2010-01-01')->text_format('The year was {Y}.'); // Expected output: The year was 2010.

Parameters:
string $format A string with single-character date format codes date() surrounded by braces
Returns:
string The string with date components inserted

Definition at line 234 of file habaridatetime.php.


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