mts-booking-library 1.3.18 → 1.3.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/README.md +6 -20
  2. package/lib/booking/booking.d.ts +2 -0
  3. package/lib/booking/booking.js +3 -3
  4. package/lib/booking/journeyBooking.d.ts +17 -10
  5. package/lib/booking/journeyBooking.js +43 -27
  6. package/lib/booking/serviceBooking.d.ts +16 -9
  7. package/lib/booking/serviceBooking.js +28 -19
  8. package/lib/booking/subscriptionBooking.d.ts +16 -9
  9. package/lib/booking/subscriptionBooking.js +28 -20
  10. package/lib/booking/tplBooking.d.ts +16 -9
  11. package/lib/booking/tplBooking.js +28 -19
  12. package/lib/mtsStorage.d.ts +3 -1
  13. package/lib/mtsStorage.js +5 -2
  14. package/lib/types/Booking.js +1 -0
  15. package/lib/types/Cart.d.ts +79 -0
  16. package/lib/types/Details.d.ts +9 -0
  17. package/lib/types/Info.d.ts +7 -0
  18. package/lib/types/Journeys/Journey.d.ts +8 -0
  19. package/lib/types/Line.d.ts +6 -0
  20. package/lib/types/Line.js +2 -0
  21. package/lib/types/Person.d.ts +7 -0
  22. package/lib/types/Person.js +2 -0
  23. package/lib/types/Subscriptions/SubscriptionAvailabilities.js +2 -0
  24. package/lib/types/Subscriptions/SubscriptionCart.js +2 -0
  25. package/lib/types/Subscriptions/SubscriptionInfo.js +2 -0
  26. package/lib/types/Subscriptions/Subscriptions.js +2 -0
  27. package/lib/types/Subscriptions/Subscrptions.d.ts +12 -0
  28. package/lib/types/Subscriptions/Subscrptions.js +2 -0
  29. package/lib/types/Subscriptions/ValidityTypes.d.ts +6 -0
  30. package/lib/types/Subscriptions/ValidityTypes.js +10 -0
  31. package/lib/types/TermsAndTariffs.d.ts +21 -0
  32. package/lib/types/TermsAndTariffs.js +2 -0
  33. package/lib/types/Tours/Tour.d.ts +18 -0
  34. package/lib/types/Tours/Tour.js +2 -0
  35. package/lib/types/common/Cart.d.ts +7 -1
  36. package/lib/utils/apiCall.js +21 -12
  37. package/package.json +1 -1
  38. package/lib/SubscriptionBooking.js +0 -148
  39. package/lib/utils/testUtils.d.ts +0 -8
  40. package/lib/utils/testUtils.js +0 -19
  41. /package/lib/{SubscriptionBooking.d.ts → types/Booking.d.ts} +0 -0
  42. /package/lib/types/{journeys/JourneyInfo.js → Cart.js} +0 -0
  43. /package/lib/types/{journeys/Stop.js → Details.js} +0 -0
  44. /package/lib/types/{journeys/Trip.js → Info.js} +0 -0
  45. /package/lib/types/{journeys → Journeys}/BusMatrix.d.ts +0 -0
  46. /package/lib/types/{journeys → Journeys}/BusMatrix.js +0 -0
  47. /package/lib/types/{subscriptions/SubscriptionAvailabilities.js → Journeys/Journey.js} +0 -0
  48. /package/lib/types/{journeys → Journeys}/JourneyCart.d.ts +0 -0
  49. /package/lib/types/{journeys → Journeys}/JourneyCart.js +0 -0
  50. /package/lib/types/{journeys → Journeys}/JourneyInfo.d.ts +0 -0
  51. /package/lib/types/{subscriptions/SubscriptionCart.js → Journeys/JourneyInfo.js} +0 -0
  52. /package/lib/types/{journeys → Journeys}/JourneySearch.d.ts +0 -0
  53. /package/lib/types/{journeys → Journeys}/JourneySearch.js +0 -0
  54. /package/lib/types/{journeys → Journeys}/Stop.d.ts +0 -0
  55. /package/lib/types/{subscriptions/SubscriptionInfo.js → Journeys/Stop.js} +0 -0
  56. /package/lib/types/{journeys → Journeys}/Trip.d.ts +0 -0
  57. /package/lib/types/{subscriptions/Subscriptions.js → Journeys/Trip.js} +0 -0
  58. /package/lib/types/{subscriptions → Subscriptions}/SubscriptionAvailabilities.d.ts +0 -0
  59. /package/lib/types/{subscriptions → Subscriptions}/SubscriptionCart.d.ts +0 -0
  60. /package/lib/types/{subscriptions → Subscriptions}/SubscriptionInfo.d.ts +0 -0
  61. /package/lib/types/{subscriptions → Subscriptions}/Subscriptions.d.ts +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export type Subscription = {
2
+ departurePhysicalAgencyStopId: number;
3
+ departureStopName: string;
4
+ destinationPhysicalAgencyStopId: number;
5
+ destinationStopName: string;
6
+ departureTime: string;
7
+ destinationTime: string;
8
+ lineName: string;
9
+ routeId: number;
10
+ routeName: string;
11
+ sellerId: number;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export declare enum ValidityTypes {
2
+ WORKING_WEEK = "WORKING_WEEK",
3
+ WEEKLY = "WEEKLY",
4
+ MONTHLY = "MONTHLY",
5
+ YEARLY = "YEARLY"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidityTypes = void 0;
4
+ var ValidityTypes;
5
+ (function (ValidityTypes) {
6
+ ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
7
+ ValidityTypes["WEEKLY"] = "WEEKLY";
8
+ ValidityTypes["MONTHLY"] = "MONTHLY";
9
+ ValidityTypes["YEARLY"] = "YEARLY";
10
+ })(ValidityTypes || (exports.ValidityTypes = ValidityTypes = {}));
@@ -0,0 +1,21 @@
1
+ export type TariffMatrix = {
2
+ tariffTypeId: number;
3
+ termsTypeId: number;
4
+ value: number;
5
+ quantity: number;
6
+ }[][];
7
+ export type TariffType = {
8
+ name: string;
9
+ description: string;
10
+ requiredPassengersName: boolean;
11
+ numberOfOccupiedSeats: number;
12
+ bookingProcessDescription: string;
13
+ };
14
+ export type TermsType = {
15
+ name: string;
16
+ description: string;
17
+ isRefundAllowed: boolean;
18
+ isChangeAllowed: boolean;
19
+ validationRulesString: string;
20
+ bookingProcessDescription: string;
21
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { Info } from "../Info";
2
+ import { Line } from "../Line";
3
+ import { TariffMatrix, TariffType, TermsType } from "../TermsAndTariffs";
4
+ export type Tour = {
5
+ id: number;
6
+ line: Line;
7
+ info: Info;
8
+ tariffsMatrix: TariffMatrix;
9
+ tariffTypes: TariffType[];
10
+ termsTypes: TermsType[];
11
+ isDateOptional: boolean;
12
+ isDateRequired: boolean;
13
+ isTripMandatory: boolean;
14
+ };
15
+ export type TourTrip = {
16
+ tripId: number;
17
+ hour: Date;
18
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -13,10 +13,16 @@ export declare enum SellingMethod {
13
13
  * - TourCart: {@link ServiceCart}
14
14
  * - JourneyCart: {@link JourneyCart}
15
15
  * - SubscriptionCart: {@link SubscriptionCart}
16
+ * - TplCart: {@link TplCart}
16
17
  */
17
18
  export type Cart = {
18
- /** The id of the cart */
19
+ /**
20
+ * The id of the cart
21
+ * @deprecated Please use {@link Cart.guid} instead
22
+ */
19
23
  id: number;
24
+ /** The guid of the cart */
25
+ guid: string;
20
26
  /** The id of the seller of the tickets in the cart */
21
27
  sellerId: number;
22
28
  /** The url redirecting to the privacy policy of the seller */
@@ -106,13 +106,16 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
106
106
  mtsCode: ((_d = (_c = (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
107
107
  message: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
108
108
  };
109
- if (debug) {
110
- console.log("GET_ResponseError", url, resError);
109
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
110
+ console.log("GET_ResponseAxiosError", url, resError);
111
111
  }
112
112
  reject(resError);
113
113
  }
114
114
  else {
115
115
  resError = __assign(__assign({}, error_1), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
116
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
117
+ console.log("GET_ResponseError", url, resError);
118
+ }
116
119
  reject(resError);
117
120
  }
118
121
  return [3 /*break*/, 3];
@@ -136,7 +139,7 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
136
139
  throw new Error("MTS Library Error! makePost: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
137
140
  }
138
141
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
139
- var response, filteredResponse, error_2, resError;
142
+ var response, filteredResponse, error_2, resError, resError;
140
143
  var _a, _b, _c, _d, _e, _f, _g;
141
144
  return __generator(this, function (_h) {
142
145
  switch (_h.label) {
@@ -161,14 +164,17 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
161
164
  mtsCode: ((_d = (_c = (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
162
165
  message: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
163
166
  };
164
- if (debug) {
165
- console.log("POST_ResponseError", url, resError);
167
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
168
+ console.log("POST_ResponseAxiosError", url, resError);
166
169
  }
167
170
  reject(resError);
168
171
  }
169
172
  else {
170
- // Not a axios error, return the error as is
171
- reject(error_2);
173
+ resError = __assign(__assign({}, error_2), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
174
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
175
+ console.log("POST_ResponseError", url, resError);
176
+ }
177
+ reject(resError);
172
178
  }
173
179
  return [3 /*break*/, 3];
174
180
  case 3: return [2 /*return*/];
@@ -191,7 +197,7 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
191
197
  throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
192
198
  }
193
199
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
194
- var response, filteredResponse, error_3, resError;
200
+ var response, filteredResponse, error_3, resError, resError;
195
201
  var _a, _b, _c, _d, _e, _f, _g;
196
202
  return __generator(this, function (_h) {
197
203
  switch (_h.label) {
@@ -216,14 +222,17 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
216
222
  mtsCode: ((_d = (_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
217
223
  message: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
218
224
  };
219
- if (debug) {
220
- console.log("DELETE_ResponseError", url, resError);
225
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
226
+ console.log("DELETE_ResponseAxiosError", url, resError);
221
227
  }
222
228
  reject(resError);
223
229
  }
224
230
  else {
225
- // Not a axios error, return the error as is
226
- reject(error_3);
231
+ resError = __assign(__assign({}, error_3), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
232
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
233
+ console.log("DELETE_ResponseError", url, resError);
234
+ }
235
+ reject(resError);
227
236
  }
228
237
  return [3 /*break*/, 3];
229
238
  case 3: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.3.18",
3
+ "version": "1.3.19",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,148 +0,0 @@
1
- "use strict";
2
- // import { MTSEnvs } from "../config";
3
- // import { ServiceBooking } from "../booking/serviceBooking";
4
- // import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
5
- // import { Service, ServiceTripsResponse } from "../types/services/Service";
6
- // import { GetBuyerPassengersDetailsResponse } from "../types/common/Person";
7
- // import { GetPaymentInformationFromGatewayResponse, GetSellerGatewaysResponse, PaymentMethods } from "../types/common/Payment";
8
- // import { useTestState } from "../mtsStorage";
9
- // import { SubscriptionBooking } from "../booking/subscriptionBooking";
10
- // // Load .env file
11
- // require('dotenv').config();
12
- // // How to run the test: npm run test -- SubscriptionBooking.test.ts
13
- // describe("SubscriptionBooking", () => {
14
- // const timeOut = 120000;
15
- // const sub_key = process.env.OCP_SUB_KEY_MTS;
16
- // const access_token = process.env.ACCESS_TOKEN;
17
- // const sellerId = 8; // ATV
18
- // // Define localStorage for local testing
19
- // if (typeof localStorage === "undefined" || localStorage === null) {
20
- // var LocalStorage = require("node-localstorage").LocalStorage;
21
- // global.localStorage = new LocalStorage("./scratch");
22
- // }
23
- // test("search_tpl", async () => {
24
- // const booking = new SubscriptionBooking(MTSEnvs.TEST, sub_key!, true, SubscriptionBooking.Languages.EN, access_token, sellerId);
25
- // // First, get the departures and destinations
26
- // const departures = await booking.getSubscriptionsDepartures() as string[];
27
- // expect(departures.length).toBeGreaterThan(0);
28
- // expect(departures).toContain("BARDOLINO AUTOSTAZIONE");
29
- // const selectedDeparture = "BARDOLINO AUTOSTAZIONE";
30
- // const destinations = await booking.getSubscriptionsDestinations(selectedDeparture) as string[];
31
- // expect(destinations.length).toBeGreaterThan(0);
32
- // expect(destinations).toContain("GARDA AUTOSTAZIONE");
33
- // const selectedDestination = "GARDA AUTOSTAZIONE";
34
- // // Then get the validity types
35
- // const validityTypes = await booking.getSubscriptionsValidityTypes(selectedDeparture, selectedDestination) as SubscriptionBooking.ValidityTypes[];
36
- // expect(validityTypes.length).toBeGreaterThan(0);
37
- // for (const validityType of validityTypes) {
38
- // // Check that all returned validity types are valid
39
- // expect(Object.values(SubscriptionBooking.ValidityTypes).includes(validityType)).toBe(true);
40
- // }
41
- // }, timeOut);
42
- // const createCart = async (booking: ServiceBooking): Promise<ServiceCart> => {
43
- // const servicesResponse = await booking.getServices(ServiceBooking.Currencies.EUR);
44
- // const services = servicesResponse as Service[];
45
- // // Build create cart request
46
- // let tariffsMatrix = services[0].tariffsMatrix;
47
- // tariffsMatrix[0][0].quantity = 1;
48
- // const createServiceCartRequest: CreateServiceCartRequest = {
49
- // currency: ServiceBooking.Currencies.EUR,
50
- // service: {
51
- // serviceId: services[0].id,
52
- // tariffsMatrix: tariffsMatrix
53
- // }
54
- // };
55
- // // Create cart
56
- // const cart = await booking.createServiceCart(createServiceCartRequest) as ServiceCart;
57
- // return cart;
58
- // }
59
- // test("create_service_cart", async () => {
60
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
61
- // const cart = await createCart(booking);
62
- // // Check that the cartId was saved to the local storage
63
- // expect(useTestState().getState().cartId).toBe(cart.id);
64
- // expect(booking.cartId).toBe(cart.id);
65
- // // Test the booking status (we test only the Buyer and passenger data, as it will always be required)
66
- // expect(booking.bookingStepsToStatus.get(ServiceBooking.BookingSteps.BUYER_PASSENGERS)).toStrictEqual([ true, false, true ]);
67
- // expect(booking.bookingStepsToStatus.get(ServiceBooking.BookingSteps.ISSUE)).toStrictEqual([ false, false, true ]);
68
- // // Test booking due date
69
- // expect(booking.bookingDueDate?.toISOString()).toBe(new Date(cart.bookingDueDate).toISOString());
70
- // // Test expired tickets
71
- // expect(cart.hasIssuedTickets).toBe(false);
72
- // // Test seller data
73
- // expect(booking.getSellerId()).toBe(cart.sellerId);
74
- // expect(cart.sellerPrivacyUrl.length).toBeGreaterThan(0);
75
- // expect(cart.sellerTermsUrl.length).toBeGreaterThan(0);
76
- // // Now try to get the cart
77
- // const newBooking = await ServiceBooking.createBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
78
- // expect(newBooking.cartId).toBe(cart.id);
79
- // expect(newBooking.getCart()?.id).toBe(cart.id)
80
- // expect(newBooking.getSellerId()).toBe(cart.sellerId);
81
- // // Finally try to delete the cart
82
- // await booking.deleteCart();
83
- // expect(booking.getCart()).toBe(undefined);
84
- // expect(useTestState().getState().cartId).toBe(undefined);
85
- // }, timeOut);
86
- // test("get_edit_buyer_data", async () => {
87
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
88
- // const cart = await createCart(booking);
89
- // // First, try to get the buyer data
90
- // let buyerDataResponse = await booking.getBuyerPassengersDetails();
91
- // expect((buyerDataResponse as GetBuyerPassengersDetailsResponse).passengers.length).toBe(0);
92
- // let buyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
93
- // expect(buyer).toBe(null);
94
- // // Now try to edit the buyer data
95
- // buyer = {
96
- // id: 0,
97
- // name: "TestName",
98
- // lastName: "TestSurname",
99
- // email: "testBookingLib@infos.it",
100
- // phoneNumber: "+391234567890"
101
- // }
102
- // await booking.updateBuyerPassengersDetails(buyer);
103
- // // Finally, get the buyer data again and check that the data was updated
104
- // buyerDataResponse = await booking.getBuyerPassengersDetails();
105
- // const updatedBuyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
106
- // expect(updatedBuyer.id).toBeGreaterThan(0);
107
- // expect(updatedBuyer.name).toBe(buyer.name);
108
- // expect(updatedBuyer.lastName).toBe(buyer.lastName);
109
- // expect(updatedBuyer.email).toBe(buyer.email);
110
- // expect(updatedBuyer.phoneNumber).toBe(buyer.phoneNumber);
111
- // // Finally try to delete the cart
112
- // await booking.deleteCart();
113
- // expect(booking.getCart()).toBe(undefined);
114
- // expect(useTestState().getState().cartId).toBe(undefined);
115
- // }, timeOut);
116
- // test("get_gateway_info", async () => {
117
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
118
- // const cart = await createCart(booking);
119
- // booking.updateSellerId(cart.sellerId);
120
- // // First, try to get the buyer data
121
- // let buyerDataResponse = await booking.getBuyerPassengersDetails();
122
- // expect((buyerDataResponse as GetBuyerPassengersDetailsResponse).passengers.length).toBe(0);
123
- // let buyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
124
- // expect(buyer).toBe(null);
125
- // // Now try to edit the buyer data
126
- // buyer = {
127
- // id: 0,
128
- // name: "TestName",
129
- // lastName: "TestSurname",
130
- // email: "testBookingLib@infos.it",
131
- // phoneNumber: "+391234567890"
132
- // }
133
- // await booking.updateBuyerPassengersDetails(buyer);
134
- // // Try to get the gateways
135
- // const gateways = await booking.getSellerGateways() as GetSellerGatewaysResponse;
136
- // if (!gateways.payPalGatewayDTO && !gateways.cardGatewayDTO) {
137
- // throw new Error("No gateways found");
138
- // }
139
- // const gateway = gateways.payPalGatewayDTO ? gateways.payPalGatewayDTO : gateways.cardGatewayDTO;
140
- // expect(gateway?.id).toBeGreaterThan(0);
141
- // // Now try to get the info
142
- // const gatewayInfo = await booking.getPaymentInformationFromGateway(gateway?.id ?? 0) as GetPaymentInformationFromGatewayResponse;
143
- // // Finally try to delete the cart
144
- // await booking.deleteCart();
145
- // expect(booking.getCart()).toBe(undefined);
146
- // expect(useTestState().getState().cartId).toBe(undefined);
147
- // }, timeOut);
148
- // });
@@ -1,8 +0,0 @@
1
- /**
2
- * This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
3
- * @param {Date | string} date the date to convert
4
- * @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
5
- * that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
6
- * @returns {string} the ISO string
7
- */
8
- export declare const getISOStringWithoutGMT: (date: Date | string | null | undefined, removeTimezone?: boolean) => string | null;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getISOStringWithoutGMT = void 0;
4
- /**
5
- * This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
6
- * @param {Date | string} date the date to convert
7
- * @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
8
- * that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
9
- * @returns {string} the ISO string
10
- */
11
- var getISOStringWithoutGMT = function (date, removeTimezone) {
12
- if (removeTimezone === void 0) { removeTimezone = true; }
13
- if (!date)
14
- return null;
15
- var newDate = new Date(date);
16
- var isoString = new Date(newDate.valueOf() - newDate.getTimezoneOffset() * 60000).toISOString();
17
- return removeTimezone ? isoString.slice(0, -1) : isoString;
18
- };
19
- exports.getISOStringWithoutGMT = getISOStringWithoutGMT;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes