
Represents a date as a value object
1.0.0b11 | Fixed a method signature 8/24/11 |
---|---|
1.0.0b10 | Fixed a bug with the constructor not properly handling unix timestamps that are negative integers 6/2/11 |
1.0.0b9 | Changed the $date attribute to be protected 3/20/11 |
1.0.0b8 | Added the $simple parameter to getFuzzyDifference() 3/15/10 |
1.0.0b7 | Added a call to fTimestamp::callUnformatCallback() in __construct() for localization support 6/1/09 |
1.0.0b6 | Backwards compatibility break - Removed getSecondsDifference(), added eq(), gt(), gte(), lt(), lte() 3/5/09 |
1.0.0b5 | Updated for new fCore API 2/16/09 |
1.0.0b4 | Fixed __construct() to properly handle the 5.0 to 5.1 change in strtotime() 1/21/09 |
1.0.0b3 | Added support for CURRENT_TIMESTAMP and CURRENT_DATE SQL keywords 1/11/09 |
1.0.0b2 | Removed the adjustment amount check from adjust() 12/31/08 |
1.0.0b | The initial implementation 2/10/08 |
A timestamp of the date
integer
Composes text using fText if loaded
string compose( string $message, mixed $component [, ... ] )
string | $message | The message to compose |
mixed | $component [, ... ] | A string or number to insert into the message |
The composed and possible translated message
Creates the date to represent, no timezone is allowed since dates don't have timezones
fDate __construct( fDate|object|string|integer $date=NULL )
fDate|object|string|integer | $date | The date to represent, NULL is interpreted as today |
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
All requests that hit this method should be requests for callbacks
callback __get( string $method )
string | $method | The method to create a callback for |
The callback for the method requested
Returns this date in Y-m-d format
string __toString( )
The Y-m-d format of this date
Changes the date by the adjustment specified, only adjustments of a day or more will be made
fDate adjust( string $adjustment )
string | $adjustment | The adjustment to make |
The adjusted date
If this date is equal to the date passed
boolean eq( fDate|object|string|integer $other_date=NULL )
fDate|object|string|integer | $other_date | The date to compare with, NULL is interpreted as today |
If this date is equal to the one passed
Formats the date
string format( string $format )
string | $format | The date() function compatible formatting string, or a format name from fTimestamp::defineFormat() |
The formatted date
Returns the approximate difference in time, discarding any unit of measure but the least specific.
The output will read like:
Examples of output for a date passed might be:
Examples of output for no date passed might be:
You would never get the following output since it includes more than one unit of time measurement:
Values that are close to the next largest unit of measure will be rounded up:
string getFuzzyDifference( fDate|object|string|integer $other_date=NULL, boolean $simple=FALSE )
string getFuzzyDifference( boolean $simple=FALSE )
fDate|object|string|integer | $other_date | The date to create the difference with, NULL is interpreted as today |
boolean | $simple | When TRUE, the returned value will only include the difference in the two dates, but not from now, ago, after or before |
The fuzzy difference in time between the this date and the one provided
If this date is greater than the date passed
boolean gt( fDate|object|string|integer $other_date=NULL )
fDate|object|string|integer | $other_date | The date to compare with, NULL is interpreted as today |
If this date is greater than the one passed
If this date is greater than or equal to the date passed
boolean gte( fDate|object|string|integer $other_date=NULL )
fDate|object|string|integer | $other_date | The date to compare with, NULL is interpreted as today |
If this date is greater than or equal to the one passed
If this date is less than the date passed
boolean lt( fDate|object|string|integer $other_date=NULL )
fDate|object|string|integer | $other_date | The date to compare with, NULL is interpreted as today |
If this date is less than the one passed
If this date is less than or equal to the date passed
boolean lte( fDate|object|string|integer $other_date=NULL )
fDate|object|string|integer | $other_date | The date to compare with, NULL is interpreted as today |
If this date is less than or equal to the one passed
Modifies the current date, creating a new fDate object
The purpose of this method is to allow for easy creation of a date based on this date. Below are some examples of formats to modify the current date:
fDate modify( string $format )
string | $format | The current date will be formatted with this string, and the output used to create a new object |
The new date