Class CMS_date

Description

Class CMS_date

Manages a date representation. Such instances can be fed with DB dates (MySQL for now), or with its elements separately (month, day, year, ...), or with a date expressed with its format. The format permits to return or set the date in the preferred user format. The stereotype formats are the same that the date() function, and typically are : "m/d/Y" for english dates "d/m/Y" for french dates

Located in /automne/classes/common/date.php (line 32)

CMS_grandFather
   |
   --CMS_date
Method Summary
 static boolean compare (CMS_date $date1, CMS_date $date2, string $operator)
 string getDay ()
 string getDayOfWeek ()
 string getDBValue ([boolean $dateOnly = false])
 string getHour ()
 string getLocalizedDate ([string $format = false])
 string getMinute ()
 string getMonth ()
 string getSecond ()
 string getTimestamp ()
 string getWeek ()
 string getYear ()
 boolean isNull ()
 cms_date moveDate ($moveTo $moveTo)
 boolean setDay (string $value)
 void setFormat (string $format)
 void setFromDBValue (string $value)
 boolean setHour (string $value)
 boolean setLocalizedDate (string $date, [boolean $canBeNull = false])
 boolean setMinute (string $value)
 boolean setMonth (string $value)
 void setNow ([boolean $dateOnly = false])
 boolean setSecond (string $value)
 boolean setYear (string $value)
 mixed _fillWithZeros (string $value, integer $length)
Methods
static compare (line 503)

Compares two dates using the given operator.

Static function.

  • return: true if the comparison is true, false otherwise
  • access: public
static boolean compare (CMS_date $date1, CMS_date $date2, string $operator)
  • CMS_date $date1: The leftmost date of the comparison
  • CMS_date $date2: The rightmost date of the comparison
  • string $operator: the comparison operator. Can be one of ==,>=,>,<=,<
getDay (line 318)

Gets the day part

  • return: the day, 0-left-filled to 2 chars
  • access: public
string getDay ()
getDayOfWeek (line 307)

Gets the Week day (0 to 6 value : 0 for sunday, 6 for saturday)

  • return: the day of the week
  • access: public
string getDayOfWeek ()
getDBValue (line 91)

Fills a DB datetime field

  • return: the value needed by MySQL for a datetime field
  • access: public
string getDBValue ([boolean $dateOnly = false])
  • boolean $dateOnly: Set to true if you don't want the time
getHour (line 352)

Gets the hour part

  • return: the hour, 0-left-filled to 2 chars
  • access: public
string getHour ()
getLocalizedDate (line 124)

Get the formatted date

  • return: the date value formatted for user viewing according to the language format
  • access: public
string getLocalizedDate ([string $format = false])
  • string $format: Optional format if not already set
getMinute (line 382)

Gets the minutes part

  • return: the minutes, 0-left-filled to 2 chars
  • access: public
string getMinute ()
getMonth (line 262)

Returns the Month part

  • return: the month, 0-left-filled to 2 chars
  • access: public
string getMonth ()
getSecond (line 412)

Gets the seconds part

  • return: the seconds, 0-left-filled to 2 chars
  • access: public
string getSecond ()
getTimestamp (line 212)

Gets the unix timestamp for the date

  • return: the unix timestamp for the date
  • access: public
string getTimestamp ()
getWeek (line 296)

Gets the Week part

  • return: the week
  • access: public
string getWeek ()
getYear (line 224)

Gets the Year part

  • return: the year, 0-left-filled to 4 chars
  • access: public
string getYear ()
isNull (line 474)

Is the date null ? 0000-00-00 is a null date.

  • access: public
boolean isNull ()
moveDate (line 526)

move a CMS_date to a given value

  • return: object moved
cms_date moveDate ($moveTo $moveTo)
  • $moveTo $moveTo: string : valid PHP strtotime() function parameter (see www.php.net for more)
setDay (line 330)

Sets the day part of the date

  • return: true on success, false on failure
  • access: public
boolean setDay (string $value)
  • string $value: the day to set to
setFormat (line 463)

Sets the date localized version format

  • access: public
void setFormat (string $format)
  • string $format: The format to set. No check is done on it.
setFromDBValue (line 107)

Initialize the date with a value picked from a MySQL datetime field : yyyy-mm-dd hh:mm:ss

  • access: public
void setFromDBValue (string $value)
  • string $value: a MySQL datetime field
setHour (line 364)

Sets the hour part of the date

  • return: true on success, false on failure
  • access: public
boolean setHour (string $value)
  • string $value: the hour to set to
setLocalizedDate (line 145)

Sets the value from a formatted date

  • return: true is successful to set it
  • access: public
boolean setLocalizedDate (string $date, [boolean $canBeNull = false])
  • string $date: The date formatted with the current format
  • boolean $canBeNull: If set to true, the function won't complain if the date is set to a null value
setMinute (line 394)

Sets the minute part of the date

  • return: true on success, false on failure
  • access: public
boolean setMinute (string $value)
  • string $value: the minute to set to
setMonth (line 274)

Sets the month part of the date

  • return: true on success, false on failure
  • access: public
boolean setMonth (string $value)
  • string $value: the month to set to
setNow (line 443)

Sets the date to now

  • access: public
void setNow ([boolean $dateOnly = false])
  • boolean $dateOnly: Set to true if you don't want to set the time
setSecond (line 424)

Sets the seconds part of the date

  • return: true on success, false on failure
  • access: public
boolean setSecond (string $value)
  • string $value: the seconds to set to
setYear (line 236)

Sets the year part of the date

  • return: true on success, false on failure
  • access: public
boolean setYear (string $value)
  • string $value: the year to set to
_fillWithZeros (line 488)

Left-fills a string with zeros

  • return: false if length of value is greater than the desired length, the filled or untouched string otherwise
  • access: private
mixed _fillWithZeros (string $value, integer $length)
  • string $value: the data to left-fill
  • integer $length: the length to fill to

Inherited Methods

Inherited From CMS_grandFather

 CMS_grandFather::autoload()
 CMS_grandFather::hasError()
 CMS_grandFather::log()
 CMS_grandFather::PHPErrorHandler()
 CMS_grandFather::raiseError()
 CMS_grandFather::setDebug()
 CMS_grandFather::setLog()
 CMS_grandFather::_raiseError()
 CMS_grandFather::__call()
Class Constants

Documentation generated on Wed, 15 Feb 2012 15:29:49 +0100 by phpDocumentor 1.4.3