@yuneta/gobj-js 7.22.0 → 7.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5103,12 +5103,13 @@ function timeTracker(tracker_name = "Time Tracker", verbose = false) {
5103
5103
  * Get the current timestamp in ISO 8601 format with milliseconds and time zone.
5104
5104
  * Example Output: "2024-02-24T14:05:30.123+0200"
5105
5105
  ************************************************************/
5106
- function current_timestamp() {
5107
- const now = /* @__PURE__ */ new Date();
5108
- const timestamp = now.toISOString().slice(0, 19);
5109
- const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
5106
+ function current_timestamp(now) {
5107
+ now = now || /* @__PURE__ */ new Date();
5108
+ const pad = (n, w) => String(n).padStart(w, "0");
5109
+ const timestamp = `${now.getFullYear()}-${pad(now.getMonth() + 1, 2)}-${pad(now.getDate(), 2)}T${pad(now.getHours(), 2)}:${pad(now.getMinutes(), 2)}:${pad(now.getSeconds(), 2)}`;
5110
+ const milliseconds = pad(now.getMilliseconds(), 3);
5110
5111
  const offsetMinutes = now.getTimezoneOffset();
5111
- return `${timestamp}.${milliseconds}${`${offsetMinutes > 0 ? "-" : "+"}${String(Math.abs(offsetMinutes) / 60).padStart(2, "0")}${String(Math.abs(offsetMinutes) % 60).padStart(2, "0")}`}`;
5112
+ return `${timestamp}.${milliseconds}${offsetMinutes > 0 ? "-" : "+"}${pad(Math.floor(Math.abs(offsetMinutes) / 60), 2)}${pad(Math.abs(offsetMinutes) % 60, 2)}`;
5112
5113
  }
5113
5114
  /********************************************
5114
5115
  * Return UTC time of right now