@teslemetry/api 0.6.10 → 0.6.12

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.
package/dist/index.cjs CHANGED
@@ -3159,6 +3159,7 @@ var TeslemetryStream = class extends events.EventEmitter {
3159
3159
  sendCache(vin, event, listener) {
3160
3160
  if (this.cache) {
3161
3161
  const vehicleCache = this.cache[vin];
3162
+ if (!vehicleCache) return;
3162
3163
  if (event === "connectivity" && vehicleCache.connectivity) for (const networkInterface in vehicleCache.connectivity) {
3163
3164
  const typedNetworkInterface = networkInterface;
3164
3165
  const status = vehicleCache.connectivity[typedNetworkInterface];
@@ -3383,12 +3384,20 @@ var TeslemetryChargingApi = class extends events.EventEmitter {
3383
3384
  //#endregion
3384
3385
  //#region src/dateHelper.ts
3385
3386
  /**
3386
- * Converts a Date object to ISO string format without milliseconds
3387
+ * Converts a Date object to RFC3339 format with local timezone offset
3387
3388
  * @param date The Date object to convert
3388
- * @returns ISO string with milliseconds removed (e.g., "2024-01-15T00:00:00Z")
3389
+ * @returns RFC3339 string with timezone offset (e.g., "2024-01-15T00:00:00+11:00")
3389
3390
  */
3390
3391
  function formatDate(date) {
3391
- return date.toISOString().replace(/\.\d{3}Z$/, "Z");
3392
+ const pad = (n, digits = 2) => String(n).padStart(digits, "0");
3393
+ const year = date.getFullYear();
3394
+ const month = pad(date.getMonth() + 1);
3395
+ const day = pad(date.getDate());
3396
+ const hours = pad(date.getHours());
3397
+ const minutes = pad(date.getMinutes());
3398
+ const seconds = pad(date.getSeconds());
3399
+ const tzOffset = -date.getTimezoneOffset();
3400
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${tzOffset >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(tzOffset) / 60))}:${pad(Math.abs(tzOffset) % 60)}`;
3392
3401
  }
3393
3402
  /**
3394
3403
  * Gets the start of today (midnight) in local timezone
@@ -5252,7 +5261,7 @@ const consoleLogger = {
5252
5261
 
5253
5262
  //#endregion
5254
5263
  //#region package.json
5255
- var version = "0.6.10";
5264
+ var version = "0.6.12";
5256
5265
 
5257
5266
  //#endregion
5258
5267
  //#region src/Teslemetry.ts
package/dist/index.mjs CHANGED
@@ -3159,6 +3159,7 @@ var TeslemetryStream = class extends EventEmitter {
3159
3159
  sendCache(vin, event, listener) {
3160
3160
  if (this.cache) {
3161
3161
  const vehicleCache = this.cache[vin];
3162
+ if (!vehicleCache) return;
3162
3163
  if (event === "connectivity" && vehicleCache.connectivity) for (const networkInterface in vehicleCache.connectivity) {
3163
3164
  const typedNetworkInterface = networkInterface;
3164
3165
  const status = vehicleCache.connectivity[typedNetworkInterface];
@@ -3383,12 +3384,20 @@ var TeslemetryChargingApi = class extends EventEmitter {
3383
3384
  //#endregion
3384
3385
  //#region src/dateHelper.ts
3385
3386
  /**
3386
- * Converts a Date object to ISO string format without milliseconds
3387
+ * Converts a Date object to RFC3339 format with local timezone offset
3387
3388
  * @param date The Date object to convert
3388
- * @returns ISO string with milliseconds removed (e.g., "2024-01-15T00:00:00Z")
3389
+ * @returns RFC3339 string with timezone offset (e.g., "2024-01-15T00:00:00+11:00")
3389
3390
  */
3390
3391
  function formatDate(date) {
3391
- return date.toISOString().replace(/\.\d{3}Z$/, "Z");
3392
+ const pad = (n, digits = 2) => String(n).padStart(digits, "0");
3393
+ const year = date.getFullYear();
3394
+ const month = pad(date.getMonth() + 1);
3395
+ const day = pad(date.getDate());
3396
+ const hours = pad(date.getHours());
3397
+ const minutes = pad(date.getMinutes());
3398
+ const seconds = pad(date.getSeconds());
3399
+ const tzOffset = -date.getTimezoneOffset();
3400
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${tzOffset >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(tzOffset) / 60))}:${pad(Math.abs(tzOffset) % 60)}`;
3392
3401
  }
3393
3402
  /**
3394
3403
  * Gets the start of today (midnight) in local timezone
@@ -5252,7 +5261,7 @@ const consoleLogger = {
5252
5261
 
5253
5262
  //#endregion
5254
5263
  //#region package.json
5255
- var version = "0.6.10";
5264
+ var version = "0.6.12";
5256
5265
 
5257
5266
  //#endregion
5258
5267
  //#region src/Teslemetry.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teslemetry/api",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "description": "API client for Teslemetry",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",