File tree Expand file tree Collapse file tree 3 files changed +43
-16
lines changed
Expand file tree Collapse file tree 3 files changed +43
-16
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,25 @@ public function __construct(string $flexidate = 'NOW')
5757 }
5858 }
5959
60+ /**
61+ * Convert Timestamp to AbraFlexi Date format.
62+ *
63+ * @param int $timpestamp
64+ *
65+ * @return \AbraFlexi\Date or NULL
66+ */
67+ public static function timestampToFlexiDate ($ timpestamp = null )
68+ {
69+ $ flexiDate = new Date ();
70+
71+ if (null !== $ timpestamp ) {
72+ $ flexiDate ->setTimestamp ($ timpestamp );
73+ }
74+
75+ return $ flexiDate ;
76+ }
77+
78+
6079 /**
6180 * Render Object as AbraFlexi::$DateFormat.
6281 *
Original file line number Diff line number Diff line change @@ -66,6 +66,26 @@ public function __toString()
6666 return $ this ->isNull ? '' : $ this ->format (self ::$ format );
6767 }
6868
69+ /**
70+ * Convert Timestamp to Flexi DateTime format.
71+ *
72+ * @param int $timpestamp
73+ *
74+ * @return string AbraFlexi DateTime or NULL
75+ */
76+ public static function timestampToFlexiDateTime ($ timpestamp = null )
77+ {
78+ $ flexiDateTime = null ;
79+
80+ if (null !== $ timpestamp ) {
81+ $ date = new \DateTime ();
82+ $ date ->setTimestamp ($ timpestamp );
83+ $ flexiDateTime = $ date ->format ('Y-m-dTH:i:s ' );
84+ }
85+
86+ return $ flexiDateTime ;
87+ }
88+
6989 /**
7090 * Easy way how to force format DateTime used.
7191 *
Original file line number Diff line number Diff line change @@ -397,33 +397,21 @@ public function controlReadOnlyColumns($data = null)
397397 */
398398 public static function timestampToFlexiDate ($ timpestamp = null )
399399 {
400- $ flexiDate = new Date ();
401-
402- if (null !== $ timpestamp ) {
403- $ flexiDate ->setTimestamp ($ timpestamp );
404- }
405-
406- return $ flexiDate ;
400+ return Date::timestampToFlexiDate ($ timpestamp );
407401 }
408402
409403 /**
410404 * Convert Timestamp to Flexi DateTime format.
411405 *
406+ * @deprecated since version 3.3 - please use \AbraFlexi\DateTime() object instead
407+ *
412408 * @param int $timpestamp
413409 *
414410 * @return string AbraFlexi DateTime or NULL
415411 */
416412 public static function timestampToFlexiDateTime ($ timpestamp = null )
417413 {
418- $ flexiDateTime = null ;
419-
420- if (null !== $ timpestamp ) {
421- $ date = new \DateTime ();
422- $ date ->setTimestamp ($ timpestamp );
423- $ flexiDateTime = $ date ->format ('Y-m-dTH:i:s ' );
424- }
425-
426- return $ flexiDateTime ;
414+ return DateTime::timestampToFlexiDateTime ($ timpestamp );
427415 }
428416
429417 /**
You can’t perform that action at this time.
0 commit comments