@@ -65,19 +65,19 @@ public function greaterThanOrEqualTo($time): bool
6565 }
6666
6767 /**
68- * build Time Modifier
68+ * Modify builder for add/sub operations.
6969 *
70- * @param string $mode
71- * @param int $value
72- * @param bool $sub
73- * @return $clone
70+ * @param string $mode second|minute|hour|day|week|month|year
71+ * @param int $value Amount to adjust
72+ * @param bool $sub If true, subtract instead of add
73+ * @return static
7474 */
7575 private function buildTimeModifier ($ mode = 'day ' , $ value = 0 , $ sub = false )
7676 {
7777 $ clone = $ this ->clone ();
78- $ date = $ clone ->format ();
78+ $ date = $ clone ->format (" Y-m-d H:i:s " );
7979 $ mode = Str::lower ($ mode );
80- $ sign = ! $ sub ? '+ ' : '- ' ;
80+ $ sign = $ sub ? '- ' : '+ ' ;
8181
8282 $ text = match ($ mode ) {
8383 'second ' , => $ value <= 1 ? 'second ' : 'seconds ' ,
@@ -163,7 +163,7 @@ private function setTimeZoneAndTimeStamp($timezone = null)
163163 }
164164
165165 /**
166- * create timestamp
166+ * timestampPrint(): rebuilds debug-like timestamp string.
167167 *
168168 * @return string
169169 */
@@ -179,7 +179,7 @@ private function timestampPrint()
179179 }
180180
181181 /**
182- * buildTimePrint
182+ * Pretty string including microseconds, tz and UTC offset (compat buildTimePrint())
183183 *
184184 * @return string
185185 */
@@ -190,6 +190,21 @@ private function buildTimePrint()
190190
191191 return "{$ date }. {$ this ->microseconds ()} {$ this ->timezone } {$ utc }" ;
192192 }
193+
194+ /**
195+ * Return a pretty timestamp with microseconds, timezone, and UTC offset.
196+ * Example: "2025-05-01 10:20:30.123456 America/New_York (-04:00)"
197+ *
198+ * @return string
199+ */
200+ public function debugTimestamp (): string
201+ {
202+ $ date = $ this ->format ('Y-m-d H:i:s ' );
203+ $ micro = $ this ->microseconds ();
204+ $ tz = $ this ->timezone ->getName ();
205+ $ offset = $ this ->format ('(P) ' );
206+ return sprintf ('%s.%s %s %s ' , $ date , $ micro , $ tz , $ offset );
207+ }
193208
194209 /**
195210 * create microseconds
@@ -198,10 +213,9 @@ private function buildTimePrint()
198213 */
199214 private function microseconds ()
200215 {
201- $ microtime = explode (' ' , microtime ());
202- $ milliseconds = (int ) round ($ microtime [0 ] * 1000000 ); // Get microseconds
203-
204- return str_pad (Str::trim ($ milliseconds ), 6 , '0 ' , STR_PAD_LEFT );
216+ $ micro = explode (' ' , microtime ());
217+ $ micros = (int ) round (((float ) ($ micro [0 ] ?? 0 )) * 1_000_000 );
218+ return str_pad ((string ) $ micros , 6 , '0 ' , STR_PAD_LEFT );
205219 }
206220
207221 /**
@@ -287,7 +301,7 @@ private static function nonExistMethod($method = null, $args = null, $clone = nu
287301 $ clone = new static ();
288302 }
289303
290- return $ clone ->$ method (...$ args );
304+ return $ clone ->$ method (...( $ args ?? []) );
291305 }
292306
293307}
0 commit comments