@@ -228,8 +228,22 @@ public function getBirthday()
228228 */
229229 public function setBirthday ($ birthday )
230230 {
231- if (!$ birthday instanceof DateTime) {
232- $ birthday = new DateTime ($ birthday );
231+ if (!$ birthday instanceof DateTime && !empty ($ birthday )) {
232+ if (ctype_digit ($ birthday ) && strlen (4 )) {
233+ $ birthday = DateTime::createFromFormat (
234+ 'Y-m-d ' ,
235+ sprintf ('%d-01-01 ' , $ birthday ),
236+ new \DateTimeZone ('UTC ' )
237+ );
238+ } elseif (strtotime ($ birthday ) === false ) {
239+ $ birthday = DateTime::createFromFormat ('Y-d-m ' , $ birthday );
240+ } else {
241+ $ birthday = new DateTime ($ birthday );
242+ }
243+ }
244+
245+ if (empty ($ birthday )) {
246+ $ birthday = false ;
233247 }
234248
235249 $ this ->birthday = $ birthday ;
@@ -271,8 +285,13 @@ public function getDeathday()
271285 public function setDeathday ($ deathday )
272286 {
273287 if (!$ deathday instanceof DateTime && !empty ($ deathday )) {
274- // Is the format Y-m-d ?
275- if (strtotime ($ deathday ) === false ) {
288+ if (ctype_digit ($ deathday ) && strlen (4 )) {
289+ $ deathday = DateTime::createFromFormat (
290+ 'Y-m-d ' ,
291+ sprintf ('%d-01-01 ' , $ deathday ),
292+ new \DateTimeZone ('UTC ' )
293+ );
294+ } elseif (strtotime ($ deathday ) === false ) {
276295 $ deathday = DateTime::createFromFormat ('Y-d-m ' , $ deathday );
277296 } else {
278297 $ deathday = new DateTime ($ deathday );
0 commit comments