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