@taskora-uni/common 1.1.0 → 1.1.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.
@@ -3,5 +3,5 @@ interface Timestamp {
3
3
  nanos: number;
4
4
  }
5
5
  export declare const timestampToIsoString: (timestamp: Timestamp) => string;
6
- export declare const isoStringToTimestamp: (isoString: string) => Timestamp;
6
+ export declare const dateToTimestamp: (value: Date | string) => Timestamp;
7
7
  export {};
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isoStringToTimestamp = exports.timestampToIsoString = void 0;
3
+ exports.dateToTimestamp = exports.timestampToIsoString = void 0;
4
4
  const timestampToIsoString = (timestamp) => new Date(timestamp.seconds * 1000 + Math.floor(timestamp.nanos / 1_000_000)).toISOString();
5
5
  exports.timestampToIsoString = timestampToIsoString;
6
- const isoStringToTimestamp = (isoString) => {
7
- const date = new Date(isoString);
6
+ const dateToTimestamp = (value) => {
7
+ const date = value instanceof Date ? value : new Date(value);
8
8
  const time = date.getTime();
9
9
  return {
10
10
  seconds: Math.floor(time / 1000),
11
11
  nanos: (time % 1000) * 1_000_000,
12
12
  };
13
13
  };
14
- exports.isoStringToTimestamp = isoStringToTimestamp;
14
+ exports.dateToTimestamp = dateToTimestamp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskora-uni/common",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Shared common modules for Taskora Uni backend services",
5
5
  "license": "MIT",
6
6
  "files": [