turf-common 1.4.2-beta.13 → 1.4.2-beta.14
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/build/src/models/booking-code-model.d.ts +1 -1
- package/build/src/models/booking-code-model.js +11 -31
- package/build/src/utils/date-util.d.ts +2 -1
- package/build/src/utils/date-util.js +7 -2
- package/build/tests/booking-code/method.spec.d.ts +1 -0
- package/build/tests/booking-code/method.spec.js +12 -0
- package/package.json +2 -2
|
@@ -45,7 +45,7 @@ export declare class BookingCode {
|
|
|
45
45
|
static getWeekday(dateCode: number): number;
|
|
46
46
|
static convertToDate(str: string): Date;
|
|
47
47
|
static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
|
|
48
|
-
static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number): void;
|
|
48
|
+
static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number, date?: Date): void;
|
|
49
49
|
static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
|
|
50
50
|
static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
|
|
51
51
|
static isValidTimeRange(timeSlot: string): boolean;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.BookingCode = void 0;
|
|
15
4
|
var time_slot_model_1 = require("./time-slot-model");
|
|
@@ -233,27 +222,18 @@ var BookingCode = /** @class */ (function () {
|
|
|
233
222
|
}
|
|
234
223
|
};
|
|
235
224
|
//---------------------
|
|
236
|
-
BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes) {
|
|
225
|
+
BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes, date) {
|
|
237
226
|
if (bookingDelayInMinutes === void 0) { bookingDelayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
};
|
|
249
|
-
var timeFormat = new Intl.DateTimeFormat("en-US", __assign(__assign({}, options), { hour: "2-digit", minute: "2-digit", hour12: false }));
|
|
250
|
-
var currentTimeObj = timeFormat.format(now).replace(/:/g, "");
|
|
251
|
-
if (fromTime < currentTimeObj) {
|
|
252
|
-
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
253
|
-
key: "slot.".concat(index),
|
|
254
|
-
message: ["Booking time should be in future"],
|
|
255
|
-
});
|
|
256
|
-
}
|
|
227
|
+
if (date === void 0) { date = date_util_1.dateUtilService.getIndianDate(); }
|
|
228
|
+
var now = date;
|
|
229
|
+
console.log("previousTimeChecker now", now);
|
|
230
|
+
var bookingDate = date_util_1.dateUtilService.convertStringToDate(fromDate.toString() + fromTime, "yyMMddHHmm");
|
|
231
|
+
var difference = bookingDate.getTime() - now.getTime() + bookingDelayInMinutes * 60 * 1000;
|
|
232
|
+
if (difference < 0) {
|
|
233
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
234
|
+
key: "slot.".concat(index),
|
|
235
|
+
message: ["Booking time should be in future"],
|
|
236
|
+
});
|
|
257
237
|
}
|
|
258
238
|
};
|
|
259
239
|
//---------------------
|
|
@@ -5,7 +5,8 @@ export declare class DateUtilService {
|
|
|
5
5
|
getNDaysCode(n: number): string;
|
|
6
6
|
getDateCode(date: Date): string;
|
|
7
7
|
addNDaysToDate(date: Date, n: number): Date;
|
|
8
|
-
convertStringToDate(dateString: string, format: string): Date;
|
|
8
|
+
convertStringToDate(dateString: string, format: string, offset?: number): Date;
|
|
9
|
+
getIndianDate(date?: Date): Date;
|
|
9
10
|
isInPast(date: Date): boolean;
|
|
10
11
|
getDateFromDatabaseDate: (date: string) => Date;
|
|
11
12
|
noOfDaysBetweenDates: (date1: Date, date2: Date) => number;
|
|
@@ -31,12 +31,17 @@ var DateUtilService = /** @class */ (function () {
|
|
|
31
31
|
DateUtilService.prototype.addNDaysToDate = function (date, n) {
|
|
32
32
|
return (0, date_fns_1.add)(date, { days: n });
|
|
33
33
|
};
|
|
34
|
-
DateUtilService.prototype.convertStringToDate = function (dateString, format) {
|
|
34
|
+
DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
|
|
35
|
+
if (offset === void 0) { offset = 330 * 60 * 1000; }
|
|
35
36
|
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
37
|
// IST has a fixed offset of UTC+5:30
|
|
37
|
-
var indianDate = new Date(parsedDate.getTime() +
|
|
38
|
+
var indianDate = new Date(parsedDate.getTime() + offset);
|
|
38
39
|
return indianDate;
|
|
39
40
|
};
|
|
41
|
+
DateUtilService.prototype.getIndianDate = function (date) {
|
|
42
|
+
if (date === void 0) { date = new Date(); }
|
|
43
|
+
return new Date(date.getTime() + 330 * 60 * 1000);
|
|
44
|
+
};
|
|
40
45
|
DateUtilService.prototype.isInPast = function (date) {
|
|
41
46
|
return date < new Date();
|
|
42
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 001005_0P_1,006010_2P_1,011999_5P_1
|
|
3
|
+
// 000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var _model_1 = require("../../@model");
|
|
6
|
+
// 1_5#1#1#0P,1_5#3#0.95#5P,1_5#6#0.93#7P,1_5#12#0.9#10P,6_10#1#0.98#2P,6_10#3#0.931#6.9P,6_10#6#0.9114#8.86P,6_10#12#0.882#11.8P,11_99#1#0.95#5P,11_99#3#0.9025#9.75P,11_99#6#0.8835#11.65P,11_99#12#0.855#14.5P
|
|
7
|
+
describe("AppController (e2e)", function () {
|
|
8
|
+
it("Method Testing ", function () {
|
|
9
|
+
_model_1.BookingCode.previousTimeChecker("2115", 240428, 0, 45);
|
|
10
|
+
_model_1.BookingCode.previousTimeChecker("2109", 240428, 0, 51);
|
|
11
|
+
});
|
|
12
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turf-common",
|
|
3
|
-
"version": "1.4.2-beta.
|
|
3
|
+
"version": "1.4.2-beta.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
|
|
15
15
|
"version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
|
|
16
16
|
"test": "jest",
|
|
17
|
-
"test:pattern": "jest -i
|
|
17
|
+
"test:pattern": "jest -i method",
|
|
18
18
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
|
|
19
19
|
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
|
20
20
|
},
|