1919 * - Add/subtract helpers: addSeconds/Minutes/Hours/Days/Weeks/Months/Years and sub*
2020 * - Formatting: format(), toDateTimeString(), toJsTimer(), timestamp()
2121 * - Range helper: dateRange()
22- * - Text features/config: config(), greeting (via __greeting ), timeAgo (via __timeAgo )
22+ * - Text features/config: config(), greeting (via greeting ), timeAgo (via timeAgo )
2323 *
2424 * All methods are documented at their definitions for clarity.
2525 */
@@ -81,8 +81,8 @@ public function __construct($date = null, $timezone = null)
8181 $ this ->timezone = TimeHelper::configureAndSetTimezone ($ timezone );
8282 }
8383
84- if (empty ($ this ->date )){
85- $ clone = $ this ->__setDate ($ date );
84+ if (empty ($ this ->date )) {
85+ $ clone = $ this ->setDate ($ date );
8686
8787 $ this ->date = $ clone ->date ;
8888 $ this ->timestamp = $ clone ->timestamp ;
@@ -91,7 +91,7 @@ public function __construct($date = null, $timezone = null)
9191
9292 // clone copy of self
9393 if (!self ::isTimeInstance ()){
94- self ::$ staticData = clone $ this ;
94+ self ::$ staticData = $ this -> copy () ;
9595 }
9696 }
9797
@@ -288,7 +288,7 @@ public function subYears($value = 0)
288288 */
289289 public function createFromFormat ($ datetime , $ format = 'm/d/Y h:i:sa ' )
290290 {
291- return $ this ->__setDate (
291+ return $ this ->setDate (
292292 self ::timestamp ($ datetime , $ format )
293293 );
294294 }
@@ -300,7 +300,7 @@ public function createFromFormat($datetime, $format = 'm/d/Y h:i:sa')
300300 */
301301 public function date ($ date )
302302 {
303- return $ this ->__setDate ($ date );
303+ return $ this ->setDate ($ date );
304304 }
305305
306306 /**
@@ -320,7 +320,7 @@ public function now()
320320 */
321321 public function today ()
322322 {
323- return $ this ->__setDate ('today ' );
323+ return $ this ->setDate ('today ' );
324324 }
325325
326326 /**
@@ -330,7 +330,7 @@ public function today()
330330 */
331331 public function yesterday ()
332332 {
333- return $ this ->__setDate ('yesterday ' );
333+ return $ this ->setDate ('yesterday ' );
334334 }
335335
336336 /**
@@ -346,8 +346,8 @@ public function yesterday()
346346 */
347347 public function format ($ format = null , $ date = null )
348348 {
349- if (!empty ($ date )){
350- $ clone = $ this ->__setDate ($ date );
349+ if (!empty ($ date )) {
350+ $ clone = $ this ->setDate ($ date );
351351 $ this ->date = $ clone ->date ;
352352 }
353353
@@ -467,7 +467,7 @@ public static function config(?array $options = [])
467467 * Get the stored date time
468468 * @return int
469469 */
470- public function __getDate ()
470+ public function getDate ()
471471 {
472472 return (int ) $ this ->date ;
473473 }
@@ -476,63 +476,63 @@ public function __getDate()
476476 * Get the number of seconds between the stored time and the current time.
477477 * @return mixed
478478 */
479- public function __getSecond ()
479+ public function getSecond ()
480480 {
481- return $ this ->__timeDifference ('sec ' );
481+ return $ this ->timeDifference ('sec ' );
482482 }
483483
484484 /**
485485 * Get the number of minutes between the stored time and the current time.
486486 * @return mixed
487487 */
488- public function __getMin ()
488+ public function getMin ()
489489 {
490- return $ this ->__timeDifference ('mins ' );
490+ return $ this ->timeDifference ('mins ' );
491491 }
492492
493493 /**
494494 * Get the number of hours between the stored time and the current time.
495495 * @return mixed
496496 */
497- public function __getHour ()
497+ public function getHour ()
498498 {
499- return $ this ->__timeDifference ('hour ' );
499+ return $ this ->timeDifference ('hour ' );
500500 }
501501
502502 /**
503503 * Get the number of days between the stored time and the current time.
504504 * @return mixed
505505 */
506- public function __getDay ()
506+ public function getDay ()
507507 {
508- return $ this ->__timeDifference ('days ' );
508+ return $ this ->timeDifference ('days ' );
509509 }
510510
511511 /**
512512 * Get the number of weeks between the stored time and the current time.
513513 * @return mixed
514514 */
515- public function __getWeek ()
515+ public function getWeek ()
516516 {
517- return $ this ->__timeDifference ('weeks ' );
517+ return $ this ->timeDifference ('weeks ' );
518518 }
519519
520520 /**
521521 * Get the number of months between the stored time and the current time.
522522 * @return mixed
523523 */
524- public function __getMonth ()
524+ public function getMonth ()
525525 {
526- return $ this ->__timeDifference ('month ' );
526+ return $ this ->timeDifference ('month ' );
527527 }
528528
529529 /**
530530 * Get the number of years between the stored time and the current time.
531531 * @return mixed
532532 */
533- public function __getYear ()
533+ public function getYear ()
534534 {
535- return $ this ->__timeDifference ('year ' );
535+ return $ this ->timeDifference ('year ' );
536536 }
537537
538538 /**
@@ -541,7 +541,7 @@ public function __getYear()
541541 *
542542 * @return string
543543 */
544- public function __greeting ($ date = 'now ' )
544+ public function greeting ($ date = 'now ' )
545545 {
546546 $ clone = $ this ->clone ();
547547 $ clone ->date = TimeHelper::setPassedDate ($ date );
@@ -576,7 +576,7 @@ public function __greeting($date = 'now')
576576 *
577577 * @return mixed
578578 */
579- public function __timeDifferenceBetween ($ firstDate , $ lastDate , $ mode = null )
579+ public function timeDifferenceBetween ($ firstDate , $ lastDate , $ mode = null )
580580 {
581581 $ clone = $ this ->clone ();
582582
@@ -597,7 +597,7 @@ public function __timeDifferenceBetween($firstDate, $lastDate, $mode = null)
597597 *
598598 * @return mixed
599599 */
600- public function __timeDifference ($ mode = null )
600+ public function timeDifference ($ mode = null )
601601 {
602602 $ clone = $ this ->clone ();
603603
@@ -621,17 +621,17 @@ public function __timeDifference($mode = null)
621621 *
622622 * @return string
623623 */
624- public function __timeAgo ($ mode = null )
624+ public function timeAgo ($ mode = null )
625625 {
626- $ diff = $ this ->__timeDifference ();
626+ $ diff = $ this ->timeDifference ();
627627
628628 $ minutes = $ diff ['mins ' ];
629629 $ seconds = $ diff ['sec ' ];
630630 $ hours = $ diff ['hour ' ];
631631 $ days = $ diff ['days ' ];
632632 $ weeks = $ diff ['weeks ' ];
633633 $ years = $ diff ['year ' ];
634- $ date = $ this ->__getDate ();
634+ $ date = $ this ->getDate ();
635635 $ text = self ::getText ();
636636
637637 if ($ days === 0 && $ hours === 0 && $ minutes < 1 ) {
@@ -732,8 +732,8 @@ public function __debugInfo(): array
732732 'formatted ' => date ('Y-m-d H:i:s ' , $ time ),
733733 'timezone ' => (string ) ($ this ->timezoneName ?? $ this ->timezone ),
734734 'utc_offset ' => ($ this ->utcOffset ?? date ('(P) ' , $ time )),
735- 'greeting ' => $ this ->__greeting ($ time ),
736- 'time_ago_short ' => $ this ->__timeAgo ('short ' ),
735+ 'greeting ' => $ this ->greeting ($ time ),
736+ 'time_ago_short ' => $ this ->timeAgo ('short ' ),
737737 ];
738738 }
739739}
0 commit comments