@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.
@@ -5102,12 +5102,13 @@ function timeTracker(tracker_name = "Time Tracker", verbose = false) {
5102
5102
  * Get the current timestamp in ISO 8601 format with milliseconds and time zone.
5103
5103
  * Example Output: "2024-02-24T14:05:30.123+0200"
5104
5104
  ************************************************************/
5105
- function current_timestamp() {
5106
- const now = /* @__PURE__ */ new Date();
5107
- const timestamp = now.toISOString().slice(0, 19);
5108
- const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
5105
+ function current_timestamp(now) {
5106
+ now = now || /* @__PURE__ */ new Date();
5107
+ const pad = (n, w) => String(n).padStart(w, "0");
5108
+ 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)}`;
5109
+ const milliseconds = pad(now.getMilliseconds(), 3);
5109
5110
  const offsetMinutes = now.getTimezoneOffset();
5110
- return `${timestamp}.${milliseconds}${`${offsetMinutes > 0 ? "-" : "+"}${String(Math.abs(offsetMinutes) / 60).padStart(2, "0")}${String(Math.abs(offsetMinutes) % 60).padStart(2, "0")}`}`;
5111
+ return `${timestamp}.${milliseconds}${offsetMinutes > 0 ? "-" : "+"}${pad(Math.floor(Math.abs(offsetMinutes) / 60), 2)}${pad(Math.abs(offsetMinutes) % 60, 2)}`;
5111
5112
  }
5112
5113
  /********************************************
5113
5114
  * Return UTC time of right now