Mage_Eav_Model_Entity_Attribute_Backend_Datetime Class Reference

Inheritance diagram for Mage_Eav_Model_Entity_Attribute_Backend_Datetime:

Mage_Eav_Model_Entity_Attribute_Backend_Abstract Mage_Eav_Model_Entity_Attribute_Backend_Interface Mage_Catalog_Model_Product_Attribute_Backend_Startdate

List of all members.

Public Member Functions

 beforeSave ($object)
 formatDate ($date)


Detailed Description

Definition at line 27 of file Datetime.php.


Member Function Documentation

beforeSave ( object  ) 

Reimplemented from Mage_Eav_Model_Entity_Attribute_Backend_Abstract.

Reimplemented in Mage_Catalog_Model_Product_Attribute_Backend_Startdate.

Definition at line 29 of file Datetime.php.

00030     {
00031         $_formated = $object->getData($this->getAttribute()->getName() . '_is_formated');
00032         if (!$_formated) {
00033             try {
00034                 $value = $this->formatDate($object->getData($this->getAttribute()->getName()));
00035             } catch (Exception $e) {
00036                 throw new Exception("Invalid date.");
00037             }
00038             $object->setData($this->getAttribute()->getName(), $value);
00039             $object->setData($this->getAttribute()->getName() . '_is_formated', true);
00040         }
00041     }

formatDate ( date  ) 

Prepare date for save in DB

string format used from input fields (all date input fields need apply locale settings) int value can be declared in code (this meen whot we use valid date)

Parameters:
string | int $date
Returns:
string

Definition at line 52 of file Datetime.php.

00053     {
00054         if (empty($date)) {
00055             return null;
00056         }
00057         // unix timestamp given - simply instantiate date object
00058         if (preg_match('/^[0-9]+$/', $date)) {
00059             $date = new Zend_Date((int)$date);
00060         }
00061         // parse this date in current locale, do not apply GMT offset
00062         else {
00063             $date = Mage::app()->getLocale()->date($date,
00064                Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
00065                null, false
00066             );
00067         }
00068         return $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
00069     }


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

Generated on Sat Jul 4 17:24:10 2009 for Magento by  doxygen 1.5.8