Class: I2CE Date: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 68: Line 68:
Constructor method to create a new I2CE_Date object.
Constructor method to create a new I2CE_Date object.
*Signature: private function __construct($type)
*Signature: private function __construct($type)
Parameters:
*Parameters:
* integer $type<br/>The type of date object created.  It defaults to date and time.
** integer $type <br/>The type of date object created.  It defaults to date and time.
**Default Value: self::DATE_TIME  
***Default Value: self::DATE_TIME  
===addMonthDayElement()===
===addMonthDayElement()===
Add a selection drop down for the month and date to be selected.
Add a selection drop down for the month and date to be selected.
*Signature: static public function addMonthDayElement($template,$name,$default,$showError,$node,$hidden,$blank)
*Signature: static public function addMonthDayElement($template,$name,$default,$showError,$node,$hidden,$blank)
Parameters:
*Parameters:
*$template  
*$template  
* [http://www.php.net/manual/en/language.types.string.php string ] $name<br/>The name of the selection element
** [http://www.php.net/manual/en/language.types.string.php string ] $name <br/>The name of the selection element
* [[Class: I2CE_Date | I2CE_Date]] $default<br/>The default I2CE_Date object to use to preset the value.
** [[Class: I2CE_Date | I2CE_Date]] $default <br/>The default I2CE_Date object to use to preset the value.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError<br/>A flag if this field is currently invalid to mark it as such.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError <br/>A flag if this field is currently invalid to mark it as such.
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>The node to append the element to.
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node <br/>The node to append the element to.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden<br/>Set to true if the form element should be hidden. Defaults to false
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden <br/>Set to true if the form element should be hidden. Defaults to false
**Default Value: false
***Default Value: false
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $blank<br/>Set to true if this element should have a blank entry option. Defaults to false.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $blank <br/>Set to true if this element should have a blank entry option. Defaults to false.
**Default Value: false  
***Default Value: false  
===addTimeElement()===
===addTimeElement()===
Add a selection drop down for the hour, minute and second to be selected.
Add a selection drop down for the hour, minute and second to be selected.
*Signature: static public function addTimeElement($template,$name,$default,$showError,$node,$hidden)
*Signature: static public function addTimeElement($template,$name,$default,$showError,$node,$hidden)
Parameters:
*Parameters:
*$template  
*$template  
* [http://www.php.net/manual/en/language.types.string.php string ] $name<br/>The name of the selection element
** [http://www.php.net/manual/en/language.types.string.php string ] $name <br/>The name of the selection element
* [[Class: I2CE_Date | I2CE_Date]] $default<br/>The default I2CE_Date object to use to preset the value.
** [[Class: I2CE_Date | I2CE_Date]] $default <br/>The default I2CE_Date object to use to preset the value.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError<br/>A flag if this field is currently invalid to mark it as such.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError <br/>A flag if this field is currently invalid to mark it as such.
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>The node to append the element to.
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node <br/>The node to append the element to.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden<br/>Set to true if the form element should be hidden.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden <br/>Set to true if the form element should be hidden.
**Default Value: false  
***Default Value: false  
===addYearElement()===
===addYearElement()===
Add a selection drop down for the year to be selected.
Add a selection drop down for the year to be selected.
*Signature: static public function addYearElement($template,$name,$default,$showError,$node,$year_range,$hidden,$blank)
*Signature: static public function addYearElement($template,$name,$default,$showError,$node,$year_range,$hidden,$blank)
Parameters:
*Parameters:
*$template  
*$template  
* [http://www.php.net/manual/en/language.types.string.php string ] $name<br/>The name of the selection element
** [http://www.php.net/manual/en/language.types.string.php string ] $name <br/>The name of the selection element
* [[Class: I2CE_Date | I2CE_Date]] $default<br/>The default I2CE_Date object to use to preset the value.
** [[Class: I2CE_Date | I2CE_Date]] $default <br/>The default I2CE_Date object to use to preset the value.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError<br/>A flag if this field is currently invalid to mark it as such.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $showError <br/>A flag if this field is currently invalid to mark it as such.
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>The node to append the element to.
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node <br/>The node to append the element to.
* [http://www.php.net/manual/en/language.types.array.php array ] $year_range<br/>The range of years to use for the drop down.
** [http://www.php.net/manual/en/language.types.array.php array ] $year_range <br/>The range of years to use for the drop down.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden<br/>Set to true if the form element should be hidden. Defaults to false.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $hidden <br/>Set to true if the form element should be hidden. Defaults to false.
**Default Value: false
***Default Value: false
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $blank<br/>Set to true if this element should have a blank entry option. Defaults to false.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $blank <br/>Set to true if this element should have a blank entry option. Defaults to false.
**Default Value: false  
***Default Value: false  
===before()===
===before()===
Determines if a date is before the given date.
Determines if a date is before the given date.
*Signature: public function before($date)
*Signature: public function before($date)
*Parameters:
** [[Class: I2CE_Date | I2CE_Date]] $date
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* [[Class: I2CE_Date | I2CE_Date]] $date
===blank()===
===blank()===
Create a blank date object with no values set for anything.
Create a blank date object with no values set for anything.
*Signature: static public function blank($type)
*Signature: static public function blank($type)
*Parameters:
** integer $type <br/>The type of date object created.  It defaults to date and time.
***Default Value: self::DATE_TIME
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $type<br/>The type of date object created.  It defaults to date and time.
**Default Value: self::DATE_TIME
===compare()===
===compare()===
Compares a date to this one and returns -1 if it is before, 0 if the same and 1 if after
Compares a date to this one and returns -1 if it is before, 0 if the same and 1 if after this date.
this date.
*Signature: public function compare($date)
*Signature: public function compare($date)
*Parameters:
** [[Class: I2CE_Date | I2CE_Date]] $date
*Returns: integer
*Returns: integer
Parameters:
* [[Class: I2CE_Date | I2CE_Date]] $date
===day()===
===day()===
*Signature: public function day()
*Signature: public function day()
*Returns: integer The day part of the date.
*Returns: integer<br/>The day part of the date.
===dbFormat()===
===dbFormat()===
Formats the date to be saved to MySQL
Formats the date to be saved to MySQL Formats the date object to a string that MySQL will recognize based on the date type.
 
Formats the date object to a string that MySQL will recognize based on the date type.
*Signature: public function dbFormat()
*Signature: public function dbFormat()
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
Line 144: Line 141:
Determines if one date is identical to another.
Determines if one date is identical to another.
*Signature: public function equals($date)
*Signature: public function equals($date)
*Parameters:
** [[Class: I2CE_Date | I2CE_Date]] $date
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* [[Class: I2CE_Date | I2CE_Date]] $date
===fromDB()===
===fromDB()===
Creates a date from a MySQL database formatted string
Creates a date from a MySQL database formatted string The type of this date object is determined by the string.  The possible types are Month/Day ('0000-MM-DD'), Year Only ('YYYY-00-00'), Date ('YYYY-MM-DD'), Date/Time ('YYYY-MM-DD HH:MM:SS'), and Time Only ('HH:MM:SS').  If the string is blank a {@link blank() blank date} is returned.  If none of thse formats match the {@link now() current date} is returned.
 
The type of this date object is determined by the string.  The possible types are
Month/Day ('0000-MM-DD'), Year Only ('YYYY-00-00'), Date ('YYYY-MM-DD'),
Date/Time ('YYYY-MM-DD HH:MM:SS'), and Time Only ('HH:MM:SS').  If the string is blank
a {@link blank() blank date} is returned.  If none of thse formats match the
{@link now() current date} is returned.
Otherwise it is one of I2CE_DATE::DATE, I2CE_DATE::YEAR_ONLY, etc.
*Signature: static public function fromDB($dateString,$type)
*Signature: static public function fromDB($dateString,$type)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $dateString <br/>Date formatted string from MySQL
** [http://www.php.net/manual/en/language.types.integer.php int ] $type <br/>Defaults to null in which the type is guessed from the {$dateString}. Otherwise it is one of I2CE_DATE::DATE, I2CE_DATE::YEAR_ONLY, etc.
***Default Value: null
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $dateString<br/>Date formatted string from MySQL
* [http://www.php.net/manual/en/language.types.integer.php int ] $type<br/>Defaults to null in which the type is guessed from the {$dateString}.
**Default Value: null
===getDate()===
===getDate()===
Creates a date object of the type Date.
Creates a date object of the type Date.
*Signature: static public function getDate($day,$month,$year)
*Signature: static public function getDate($day,$month,$year)
*Parameters:
** integer $day <br/>Sets the day of the month to be used
***Default Value: -1
** integer $month <br/>Sets the month to be used
***Default Value: -1
** integer $year <br/>Sets the year to be used.
***Default Value: -1
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $day<br/>Sets the day of the month to be used
**Default Value: -1
* integer $month<br/>Sets the month to be used
**Default Value: -1
* integer $year<br/>Sets the year to be used.
**Default Value: -1
===getDateTime()===
===getDateTime()===
Creates a date object of the type Date/Time.
Creates a date object of the type Date/Time.
*Signature: static public function getDateTime($sec,$min,$hour,$day,$month,$year)
*Signature: static public function getDateTime($sec,$min,$hour,$day,$month,$year)
*Parameters:
** integer $sec <br/>Sets the seconds to be used
***Default Value: -1
** integer $min <br/>Sets the minutes to be used
***Default Value: -1
** integer $hour <br/>Sets the hour to be used.
***Default Value: -1
** integer $day <br/>Sets the day of the month to be used
***Default Value: -1
** integer $month <br/>Sets the month to be used
***Default Value: -1
** integer $year <br/>Sets the year to be used.
***Default Value: -1
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $sec<br/>Sets the seconds to be used
**Default Value: -1
* integer $min<br/>Sets the minutes to be used
**Default Value: -1
* integer $hour<br/>Sets the hour to be used.
**Default Value: -1
* integer $day<br/>Sets the day of the month to be used
**Default Value: -1
* integer $month<br/>Sets the month to be used
**Default Value: -1
* integer $year<br/>Sets the year to be used.
**Default Value: -1
===getDay()===
===getDay()===
Create a date object of the type Month/Day
Create a date object of the type Month/Day
*Signature: static public function getDay($day,$month)
*Signature: static public function getDay($day,$month)
*Parameters:
** integer $day <br/>Sets the day of the month to be used
***Default Value: -1
** integer $month <br/>Sets the month to be used
***Default Value: -1
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $day<br/>Sets the day of the month to be used
**Default Value: -1
* integer $month<br/>Sets the month to be used
**Default Value: -1
===getMonthName()===
===getMonthName()===
The month name text to be displayed for the given month number.
The month name text to be displayed for the given month number.
*Signature: public function getMonthName($mon)
*Signature: public function getMonthName($mon)
*Parameters:
** integer $mon
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
Parameters:
* integer $mon
===getTime()===
===getTime()===
Creates a date object of the type Time.
Creates a date object of the type Time.
*Signature: static public function getTime($sec,$min,$hour)
*Signature: static public function getTime($sec,$min,$hour)
*Parameters:
** integer $sec <br/>Sets the seconds to be used
***Default Value: -1
** integer $min <br/>Sets the minutes to be used
***Default Value: -1
** integer $hour <br/>Sets the hour to be used.
***Default Value: -1
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $sec<br/>Sets the seconds to be used
**Default Value: -1
* integer $min<br/>Sets the minutes to be used
**Default Value: -1
* integer $hour<br/>Sets the hour to be used.
**Default Value: -1
===getType()===
===getType()===
get the type for this Date.
get the type for this Date.
*Signature: public function getType()
*Signature: public function getType()
*Returns: integer $type The type of date object created.
*Returns: integer<br/>$type The type of date object created.
===getValues()===
===getValues()===
Get the array of values associated to this date.
Get the array of values associated to this date.
*Signature: public function getValues()
*Signature: public function getValues()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] The keys of which match the names for generated html elements
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>The keys of which match the names for generated html elements
===getYear()===
===getYear()===
Create a date object of the type Year only.
Create a date object of the type Year only.
*Signature: static public function getYear($year)
*Signature: static public function getYear($year)
*Parameters:
** integer $year <br/>Sets the year to be used.
***Default Value: -1
*Returns: [[Class: I2CE_Date | I2CE_Date]]
*Returns: [[Class: I2CE_Date | I2CE_Date]]
Parameters:
* integer $year<br/>Sets the year to be used.
**Default Value: -1
===hour()===
===hour()===
*Signature: public function hour()
*Signature: public function hour()
*Returns: integer The hour part of the time.
*Returns: integer<br/>The hour part of the time.
===isDay()===
===isDay()===
Checks to see if the date's day matches the given day.
Checks to see if the date's day matches the given day.
*Signature: public function isDay($day)
*Signature: public function isDay($day)
*Parameters:
** integer $day
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $day
===isHour()===
===isHour()===
Checks to see if the date's hour matches the given hour.
Checks to see if the date's hour matches the given hour.
*Signature: public function isHour($hour)
*Signature: public function isHour($hour)
*Parameters:
** integer $hour
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $hour
===isMinute()===
===isMinute()===
Checks to see if the date's minute matches the given minute.
Checks to see if the date's minute matches the given minute.
*Signature: public function isMinute($minute)
*Signature: public function isMinute($minute)
*Parameters:
** integer $minute
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $minute
===isMonth()===
===isMonth()===
Checks to see if the date's month matches the given month.
Checks to see if the date's month matches the given month.
*Signature: public function isMonth($month)
*Signature: public function isMonth($month)
*Parameters:
** integer $month
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $month
===isSecond()===
===isSecond()===
Checks to see if the date's second matches the given second.
Checks to see if the date's second matches the given second.
*Signature: public function isSecond($second)
*Signature: public function isSecond($second)
*Parameters:
** integer $second
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $second
===isValid()===
===isValid()===
Checks to see if the I2CE_Date object is valid
Checks to see if the I2CE_Date object is valid This method will check to see if the date object has valid entries based on the type.
 
This method will check to see if the date object has valid entries based on the type.
*Signature: public function isValid()
*Signature: public function isValid()
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Line 273: Line 261:
Checks to see if the date's year matches the given year.
Checks to see if the date's year matches the given year.
*Signature: public function isYear($year)
*Signature: public function isYear($year)
*Parameters:
** integer $year
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]
Parameters:
* integer $year
===listMonths()===
===listMonths()===
Adds the month values to a [[Class: I2CE_Template | I2CE_Template]] object.
Adds the month values to a [[Class: I2CE_Template | I2CE_Template]] object.
*Signature: static public function listMonths($template,$selectId)
*Signature: static public function listMonths($template,$selectId)
Parameters:
*Parameters:
* [[Class: I2CE_Template | I2CE_Template]] $template
** [[Class: I2CE_Template | I2CE_Template]] $template
* [http://www.php.net/manual/en/language.types.string.php string ] $selectId<br/>The id of the element in the page to add the selections to.
** [http://www.php.net/manual/en/language.types.string.php string ] $selectId <br/>The id of the element in the page to add the selections to.
===listYears()===
===listYears()===
Adds a sequence of years to a [[Class: I2CE_Template | I2CE_Template]] object.
Adds a sequence of years to a [[Class: I2CE_Template | I2CE_Template]] object. It takes two optional arguments to limit the years to use.  The initial year to start with is 1990 and it will end with the current year.
 
It takes two optional arguments to limit the years to use.  The initial year to start with is 1990 and it will end
with the current year.
@see I2CE_Template::setData()
*Signature: static public function listYears($template,$selectId,$start,$end)
*Signature: static public function listYears($template,$selectId,$start,$end)
Parameters:
*Parameters:
* [[Class: I2CE_Template | I2CE_Template]] $template
** [[Class: I2CE_Template | I2CE_Template]] $template
* [http://www.php.net/manual/en/language.types.string.php string ] $selectId<br/>The id of the element in the page to add the selections to.
** [http://www.php.net/manual/en/language.types.string.php string ] $selectId <br/>The id of the element in the page to add the selections to.
* integer $start<br/>The year to start with
** integer $start <br/>The year to start with
**Default Value: 1990
***Default Value: 1990
* integer $end<br/>The year to end with.
** integer $end <br/>The year to end with. @see I2CE_Template::setData()
**Default Value: 0  
***Default Value: 0  
===minute()===
===minute()===
*Signature: public function minute()
*Signature: public function minute()
*Returns: integer The minute part of the time.
*Returns: integer<br/>The minute part of the time.
===month()===
===month()===
*Signature: public function month()
*Signature: public function month()
*Returns: integer The month part of the date.
*Returns: integer<br/>The month part of the date.
===now()===
===now()===
Create a new I2CE_Date object with the current or given date and/or time.
Create a new I2CE_Date object with the current or given date and/or time.
then it should be the same array structture as returned by getdate() or the one returned by I2CE_Date::getValues()
*Signature: static public function now($type,$time_stamp,$strict)
*Signature: static public function now($type,$time_stamp,$strict)
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ] I2CE_Date or false if failure on strict mode
*Parameters:
Parameters:
** integer $type <br/>The type of date object created.  It defaults to date and time.
* integer $type<br/>The type of date object created.  It defaults to date and time.
***Default Value: self::DATE_TIME
**Default Value: self::DATE_TIME
** integer $time_stamp <br/>Defaults to null in which case we use the current time stamp.  If it is an array then it should be the same array structture as returned by getdate() or the one returned by I2CE_Date::getValues()
* integer $time_stamp<br/>Defaults to null in which case we use the current time stamp.  If it is an array
***Default Value: null
**Default Value: null
** [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $strict <br/>Defaults to false.  If true, does not return now.  If 'blank', returns the blank date.
* [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $strict<br/>Defaults to false.  If true, does not return now.  If 'blank', returns the blank date.
***Default Value: false  
**Default Value: false  
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]<br/>I2CE_Date or false if failure on strict mode
===second()===
===second()===
*Signature: public function second()
*Signature: public function second()
*Returns: integer the second part of the time.
*Returns: integer<br/>the second part of the time.
===setBlank()===
===setBlank()===
Set the blank string to be used if this date is empty.
Set the blank string to be used if this date is empty.
*Signature: public function setBlank($text)
*Signature: public function setBlank($text)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $text<br/>The text to use.
** [http://www.php.net/manual/en/language.types.string.php string ] $text <br/>The text to use.
===setType()===
===setType()===
Set the type for this Date.
Set the type for this Date.
*Signature: public function setType($type)
*Signature: public function setType($type)
Parameters:
*Parameters:
* integer $type<br/>The type of date object created.  It defaults to date and time.
** integer $type <br/>The type of date object created.  It defaults to date and time.
===year()===
===year()===
*Signature: public function year()
*Signature: public function year()
*Returns: integer The year part of the date.
*Returns: integer<br/>The year part of the date.




[[Category:Class Documentation]]
[[Category:Class Documentation]]

Revision as of 22:40, 16 October 2009

This article desrcibes the class I2CE_Date.

  • Location: Part of the module I2CE in the package I2CE
  • Source: Defined in the file lib/I2CE_Date.php
  • Author: Luke Duncan <lduncan@intrahealth.org>
  • Since: v1.0.0

Handles date manipulation. I2CE_Dates are used to manage date and time values for form/HTML display and for interacting with the database.

Constants

I2CE_Date::YEAR_ONLY

Constant value to signify a date only including the year. Defined as: 1

I2CE_Date::MONTH_DAY

Constant value to signify a date only including the month and day of the month. Defined as: 2

I2CE_Date::DATE

Constant value to signify a date only including the date. Defined as: 3

I2CE_Date::DATE_TIME

Constant value to signify a date only including the date and time. Defined as: 4

I2CE_Date::TIME_ONLY

Constant value to signify a date only including the time. Defined as: 5

Variables

$second

The second value for the time.

  • Type: private nteger $second

$minute

The minute value for the time.

  • Type: private nteger $minute

$hour

The hour value for the time.

  • Type: private nteger $hour

$day

The day value for the date.

  • Type: private nteger $day

$month

The month value for the date.

  • Type: private nteger $month

$year

The year value for the date.

  • Type: private nteger $year

$type

The type of I2CE_Date object based on the constant values.

Possible date types are {@link YEAR_ONLY Year}, {@link MONTH_DAY Month and Day}, {@link DATE Date}, {@link DATE_TIME Date and Time}, and {@link TIME_ONLY Time}.

  • Type: private nteger $type

$months

Array of month names.

This should be modified to handle internationalization. The array of month names.

  • Type: static public y $months

$types

A list of all valid types for I2CE_Date objects.

  • Type: static private y $types

Methods

__construct()

Constructor method to create a new I2CE_Date object.

  • Signature: private function __construct($type)
  • Parameters:
    • integer $type
      The type of date object created. It defaults to date and time.
      • Default Value: self::DATE_TIME

addMonthDayElement()

Add a selection drop down for the month and date to be selected.

  • Signature: static public function addMonthDayElement($template,$name,$default,$showError,$node,$hidden,$blank)
  • Parameters:
  • $template
    • string $name
      The name of the selection element
    • I2CE_Date $default
      The default I2CE_Date object to use to preset the value.
    • boolean $showError
      A flag if this field is currently invalid to mark it as such.
    • DOMNode $node
      The node to append the element to.
    • boolean $hidden
      Set to true if the form element should be hidden. Defaults to false
      • Default Value: false
    • boolean $blank
      Set to true if this element should have a blank entry option. Defaults to false.
      • Default Value: false

addTimeElement()

Add a selection drop down for the hour, minute and second to be selected.

  • Signature: static public function addTimeElement($template,$name,$default,$showError,$node,$hidden)
  • Parameters:
  • $template
    • string $name
      The name of the selection element
    • I2CE_Date $default
      The default I2CE_Date object to use to preset the value.
    • boolean $showError
      A flag if this field is currently invalid to mark it as such.
    • DOMNode $node
      The node to append the element to.
    • boolean $hidden
      Set to true if the form element should be hidden.
      • Default Value: false

addYearElement()

Add a selection drop down for the year to be selected.

  • Signature: static public function addYearElement($template,$name,$default,$showError,$node,$year_range,$hidden,$blank)
  • Parameters:
  • $template
    • string $name
      The name of the selection element
    • I2CE_Date $default
      The default I2CE_Date object to use to preset the value.
    • boolean $showError
      A flag if this field is currently invalid to mark it as such.
    • DOMNode $node
      The node to append the element to.
    • array $year_range
      The range of years to use for the drop down.
    • boolean $hidden
      Set to true if the form element should be hidden. Defaults to false.
      • Default Value: false
    • boolean $blank
      Set to true if this element should have a blank entry option. Defaults to false.
      • Default Value: false

before()

Determines if a date is before the given date.

blank()

Create a blank date object with no values set for anything.

  • Signature: static public function blank($type)
  • Parameters:
    • integer $type
      The type of date object created. It defaults to date and time.
      • Default Value: self::DATE_TIME
  • Returns: I2CE_Date

compare()

Compares a date to this one and returns -1 if it is before, 0 if the same and 1 if after this date.

  • Signature: public function compare($date)
  • Parameters:
  • Returns: integer

day()

  • Signature: public function day()
  • Returns: integer
    The day part of the date.

dbFormat()

Formats the date to be saved to MySQL Formats the date object to a string that MySQL will recognize based on the date type.

  • Signature: public function dbFormat()
  • Returns: string

displayDate()

Displays the date in a readable format.

  • Signature: public function displayDate()

equals()

Determines if one date is identical to another.

fromDB()

Creates a date from a MySQL database formatted string The type of this date object is determined by the string. The possible types are Month/Day ('0000-MM-DD'), Year Only ('YYYY-00-00'), Date ('YYYY-MM-DD'), Date/Time ('YYYY-MM-DD HH:MM:SS'), and Time Only ('HH:MM:SS'). If the string is blank a {@link blank() blank date} is returned. If none of thse formats match the {@link now() current date} is returned.

  • Signature: static public function fromDB($dateString,$type)
  • Parameters:
    • string $dateString
      Date formatted string from MySQL
    • int $type
      Defaults to null in which the type is guessed from the {$dateString}. Otherwise it is one of I2CE_DATE::DATE, I2CE_DATE::YEAR_ONLY, etc.
      • Default Value: null
  • Returns: I2CE_Date

getDate()

Creates a date object of the type Date.

  • Signature: static public function getDate($day,$month,$year)
  • Parameters:
    • integer $day
      Sets the day of the month to be used
      • Default Value: -1
    • integer $month
      Sets the month to be used
      • Default Value: -1
    • integer $year
      Sets the year to be used.
      • Default Value: -1
  • Returns: I2CE_Date

getDateTime()

Creates a date object of the type Date/Time.

  • Signature: static public function getDateTime($sec,$min,$hour,$day,$month,$year)
  • Parameters:
    • integer $sec
      Sets the seconds to be used
      • Default Value: -1
    • integer $min
      Sets the minutes to be used
      • Default Value: -1
    • integer $hour
      Sets the hour to be used.
      • Default Value: -1
    • integer $day
      Sets the day of the month to be used
      • Default Value: -1
    • integer $month
      Sets the month to be used
      • Default Value: -1
    • integer $year
      Sets the year to be used.
      • Default Value: -1
  • Returns: I2CE_Date

getDay()

Create a date object of the type Month/Day

  • Signature: static public function getDay($day,$month)
  • Parameters:
    • integer $day
      Sets the day of the month to be used
      • Default Value: -1
    • integer $month
      Sets the month to be used
      • Default Value: -1
  • Returns: I2CE_Date

getMonthName()

The month name text to be displayed for the given month number.

  • Signature: public function getMonthName($mon)
  • Parameters:
    • integer $mon
  • Returns: string

getTime()

Creates a date object of the type Time.

  • Signature: static public function getTime($sec,$min,$hour)
  • Parameters:
    • integer $sec
      Sets the seconds to be used
      • Default Value: -1
    • integer $min
      Sets the minutes to be used
      • Default Value: -1
    • integer $hour
      Sets the hour to be used.
      • Default Value: -1
  • Returns: I2CE_Date

getType()

get the type for this Date.

  • Signature: public function getType()
  • Returns: integer
    $type The type of date object created.

getValues()

Get the array of values associated to this date.

  • Signature: public function getValues()
  • Returns: array
    The keys of which match the names for generated html elements

getYear()

Create a date object of the type Year only.

  • Signature: static public function getYear($year)
  • Parameters:
    • integer $year
      Sets the year to be used.
      • Default Value: -1
  • Returns: I2CE_Date

hour()

  • Signature: public function hour()
  • Returns: integer
    The hour part of the time.

isDay()

Checks to see if the date's day matches the given day.

  • Signature: public function isDay($day)
  • Parameters:
    • integer $day
  • Returns: boolean

isHour()

Checks to see if the date's hour matches the given hour.

  • Signature: public function isHour($hour)
  • Parameters:
    • integer $hour
  • Returns: boolean

isMinute()

Checks to see if the date's minute matches the given minute.

  • Signature: public function isMinute($minute)
  • Parameters:
    • integer $minute
  • Returns: boolean

isMonth()

Checks to see if the date's month matches the given month.

  • Signature: public function isMonth($month)
  • Parameters:
    • integer $month
  • Returns: boolean

isSecond()

Checks to see if the date's second matches the given second.

  • Signature: public function isSecond($second)
  • Parameters:
    • integer $second
  • Returns: boolean

isValid()

Checks to see if the I2CE_Date object is valid This method will check to see if the date object has valid entries based on the type.

  • Signature: public function isValid()
  • Returns: boolean

isYear()

Checks to see if the date's year matches the given year.

  • Signature: public function isYear($year)
  • Parameters:
    • integer $year
  • Returns: boolean

listMonths()

Adds the month values to a I2CE_Template object.

  • Signature: static public function listMonths($template,$selectId)
  • Parameters:

listYears()

Adds a sequence of years to a I2CE_Template object. It takes two optional arguments to limit the years to use. The initial year to start with is 1990 and it will end with the current year.

  • Signature: static public function listYears($template,$selectId,$start,$end)
  • Parameters:
    • I2CE_Template $template
    • string $selectId
      The id of the element in the page to add the selections to.
    • integer $start
      The year to start with
      • Default Value: 1990
    • integer $end
      The year to end with. @see I2CE_Template::setData()
      • Default Value: 0

minute()

  • Signature: public function minute()
  • Returns: integer
    The minute part of the time.

month()

  • Signature: public function month()
  • Returns: integer
    The month part of the date.

now()

Create a new I2CE_Date object with the current or given date and/or time.

  • Signature: static public function now($type,$time_stamp,$strict)
  • Parameters:
    • integer $type
      The type of date object created. It defaults to date and time.
      • Default Value: self::DATE_TIME
    • integer $time_stamp
      Defaults to null in which case we use the current time stamp. If it is an array then it should be the same array structture as returned by getdate() or the one returned by I2CE_Date::getValues()
      • Default Value: null
    • mixed $strict
      Defaults to false. If true, does not return now. If 'blank', returns the blank date.
      • Default Value: false
  • Returns: mixed
    I2CE_Date or false if failure on strict mode

second()

  • Signature: public function second()
  • Returns: integer
    the second part of the time.

setBlank()

Set the blank string to be used if this date is empty.

  • Signature: public function setBlank($text)
  • Parameters:

setType()

Set the type for this Date.

  • Signature: public function setType($type)
  • Parameters:
    • integer $type
      The type of date object created. It defaults to date and time.

year()

  • Signature: public function year()
  • Returns: integer
    The year part of the date.