czapp-shared 1.0.10 → 1.0.11
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/concrete/date.ts +0 -15
- package/src/design/api.ts +1 -0
- package/test/date.test.ts +6 -13
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/concrete/date.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { MySQLDate } from '../index';
|
|
|
7
7
|
* @type Date
|
|
8
8
|
* @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
export const getMysqlDateIgnoreTZ = (date: Date): MySQLDate | undefined => {
|
|
12
11
|
let dateStr: string;
|
|
13
12
|
try {
|
|
@@ -22,20 +21,6 @@ export const getMysqlDateIgnoreTZ = (date: Date): MySQLDate | undefined => {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
/**
|
|
26
|
-
* @name getMysqlDateAllowingForTZ
|
|
27
|
-
* @param date
|
|
28
|
-
*/
|
|
29
|
-
export const getMysqlDateAllowingForTZ = (date: Date): MySQLDate => {
|
|
30
|
-
const zeroPad = (num: number): string => {
|
|
31
|
-
return num < 10 ? `0${num}` : num.toString();
|
|
32
|
-
}
|
|
33
|
-
return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}` as MySQLDate;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
24
|
/**
|
|
40
25
|
* @name convertJSDateStringToMySQLDate
|
|
41
26
|
* @description Converts a JavaScript Date object to a MySQL date string
|
package/src/design/api.ts
CHANGED
package/test/date.test.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import {
|
|
3
3
|
getMysqlDateIgnoreTZ,
|
|
4
|
-
convertJSDateStringToMySQLDate,
|
|
4
|
+
convertJSDateStringToMySQLDate,
|
|
5
|
+
dateDifferenceInDays,
|
|
6
|
+
isClientDateTooFarFromServerDate,
|
|
5
7
|
isThePreviousDay,
|
|
6
|
-
isTheSameDay,
|
|
8
|
+
isTheSameDay,
|
|
9
|
+
isValidJsDateString,
|
|
10
|
+
isValidMysqlDateString,
|
|
7
11
|
MySQLDate
|
|
8
12
|
} from '../src';
|
|
9
13
|
describe('Date', () => {
|
|
@@ -59,17 +63,6 @@ describe('Date', () => {
|
|
|
59
63
|
});
|
|
60
64
|
});
|
|
61
65
|
|
|
62
|
-
describe('getMysqlDateAllowingForTZ', () => {
|
|
63
|
-
it('should convert a JavaScript date object to a MySQL date string', () => {
|
|
64
|
-
const date = new Date("2021-01-01T07:41:23.000Z");
|
|
65
|
-
expect(getMysqlDateAllowingForTZ(date)).to.equal("2021-01-01 07:41:23");
|
|
66
|
-
});
|
|
67
|
-
it('should return undefined if the input date is invalid', () => {
|
|
68
|
-
const date = new Date("not a date");
|
|
69
|
-
expect(getMysqlDateAllowingForTZ(date)).to.be.undefined;
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
66
|
describe('convertJSDateStringToMySQLDateString', ()=> {
|
|
74
67
|
it('should convert a JavaScript date string to a MySQL date string', () => {
|
|
75
68
|
const date = "2021-01-01T07:41:23.000Z";
|