sim-node-lib 0.0.34 → 0.0.35

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.
@@ -0,0 +1,9 @@
1
+ export declare class DateUtils {
2
+ static normalizeDate(mixedDate: Date | string | undefined | Date): Date;
3
+ static validateDateBetweenTwoDatesWithDate(fromDate: Date, toDate: Date, givenDate: Date): boolean;
4
+ static validateDateBetweenTwoDatesWithString(fromDate: Date, toDate: Date, givenDate: Date): boolean;
5
+ static validateCurrentDateBetweenTwoDates(fromDate: Date, toDate: Date): boolean;
6
+ static dateToStringFormatBR(date: string): Date;
7
+ static dateToStringFormat(date: string, format: string): Date;
8
+ static getDifferenceInMinutes(startData: Date, endData: Date): number;
9
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateUtils = void 0;
4
+ const moment = require("moment");
5
+ class DateUtils {
6
+ static normalizeDate(mixedDate) {
7
+ return typeof mixedDate === 'string' ? new Date() : mixedDate;
8
+ }
9
+ static validateDateBetweenTwoDatesWithDate(fromDate, toDate, givenDate) {
10
+ return (givenDate <= DateUtils.normalizeDate(toDate) && givenDate >= DateUtils.normalizeDate(fromDate));
11
+ }
12
+ static validateDateBetweenTwoDatesWithString(fromDate, toDate, givenDate) {
13
+ return DateUtils.validateDateBetweenTwoDatesWithDate(fromDate, toDate, DateUtils.normalizeDate(givenDate));
14
+ }
15
+ static validateCurrentDateBetweenTwoDates(fromDate, toDate) {
16
+ return DateUtils.validateDateBetweenTwoDatesWithDate(fromDate, toDate, new Date());
17
+ }
18
+ static dateToStringFormatBR(date) {
19
+ return this.dateToStringFormat(date, 'DD/MM/yyyy');
20
+ }
21
+ static dateToStringFormat(date, format) {
22
+ var data = moment(date, format).toDate();
23
+ return data;
24
+ }
25
+ static getDifferenceInMinutes(startData, endData) {
26
+ return Math.trunc((Math.abs(startData.getTime() - endData.getTime()) / 36e5) * 60);
27
+ }
28
+ }
29
+ exports.DateUtils = DateUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,8 @@
16
16
  "@google-cloud/pubsub": "^3.0.1",
17
17
  "crypto": "^1.0.1",
18
18
  "dotenv": "^16.0.1",
19
- "keygenerator": "^1.0.4"
19
+ "keygenerator": "^1.0.4",
20
+ "moment": "^2.29.4"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@types/node": "^17.0.41",