File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
app/code/core/Mage/Customer/Block/Widget Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change 2525 */
2626
2727/**
28- * @method string getTime()
28+ * @method DateTime getTime()
2929 * @method $this setTime(string $value)
3030 */
3131class Mage_Customer_Block_Widget_Dob extends Mage_Customer_Block_Widget_Abstract
@@ -67,33 +67,49 @@ public function isRequired()
6767 */
6868 public function setDate ($ date )
6969 {
70- $ this ->setTime ($ date ? strtotime ($ date ) : false );
70+ if ($ date ) {
71+ try {
72+ $ dateTime = new DateTime ($ date );
73+ $ this ->setTime ($ dateTime );
74+ } catch (Exception $ e ) {
75+ }
76+ }
77+
7178 $ this ->setData ('date ' , $ date );
79+
7280 return $ this ;
7381 }
7482
7583 /**
76- * @return false|string
84+ * @return bool
85+ */
86+ public function hasTime ()
87+ {
88+ return ($ this ->getTime () instanceof DateTime);
89+ }
90+
91+ /**
92+ * @return string
7793 */
7894 public function getDay ()
7995 {
80- return $ this ->getTime () ? date ( ' d ' , $ this ->getTime ()) : '' ;
96+ return ( $ this ->hasTime ()) ? $ this ->getTime ()-> format ( ' d ' ) : '' ;
8197 }
8298
8399 /**
84- * @return false| string
100+ * @return string
85101 */
86102 public function getMonth ()
87103 {
88- return $ this ->getTime () ? date ( ' m ' , $ this ->getTime ()) : '' ;
104+ return ( $ this ->hasTime ()) ? $ this ->getTime ()-> format ( ' m ' ) : '' ;
89105 }
90106
91107 /**
92- * @return false| string
108+ * @return string
93109 */
94110 public function getYear ()
95111 {
96- return $ this ->getTime () ? date ( ' Y ' , $ this ->getTime ()) : '' ;
112+ return ( $ this ->hasTime ()) ? $ this ->getTime ()-> format ( ' o ' ) : '' ;
97113 }
98114
99115 /**
You can’t perform that action at this time.
0 commit comments