dce-reactkit 3.3.3-beta.1 → 3.3.4
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/cjs/index.js +16 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/getLocalTimeInfo.d.ts +19 -0
- package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +5 -2
- package/dist/esm/index.js +16 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/getLocalTimeInfo.d.ts +19 -0
- package/dist/esm/types/helpers/getTimeInfoInET.d.ts +5 -2
- package/dist/index.d.ts +5 -2
- package/package.json +1 -1
- package/src/client/initClient.tsx +8 -8
- package/src/helpers/getLocalTimeInfo.tsx +55 -0
- package/src/helpers/getTimeInfoInET.tsx +11 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current time info in local time
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
5
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
6
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
7
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
|
+
*/
|
|
9
|
+
declare const getLocalTimeInfo: (dateOrTimestamp?: number | Date | undefined) => {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
year: number;
|
|
12
|
+
month: number;
|
|
13
|
+
day: number;
|
|
14
|
+
hour: number;
|
|
15
|
+
hour12: number;
|
|
16
|
+
minute: number;
|
|
17
|
+
isPM: boolean;
|
|
18
|
+
};
|
|
19
|
+
export default getLocalTimeInfo;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Get current time info in US Boston Eastern Time, independent of machine
|
|
3
3
|
* timezone
|
|
4
4
|
* @author Gabe Abrams
|
|
5
|
-
* @param [
|
|
5
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
6
6
|
* @returns object with timestamp (ms since epoch) and numbers
|
|
7
|
-
* corresponding to ET time values for year, month, day, hour, minute
|
|
7
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
|
|
8
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
9
|
*/
|
|
9
10
|
declare const getTimeInfoInET: (dateOrTimestamp?: number | Date | undefined) => {
|
|
10
11
|
timestamp: number;
|
|
@@ -12,6 +13,8 @@ declare const getTimeInfoInET: (dateOrTimestamp?: number | Date | undefined) =>
|
|
|
12
13
|
month: number;
|
|
13
14
|
day: number;
|
|
14
15
|
hour: number;
|
|
16
|
+
hour12: number;
|
|
15
17
|
minute: number;
|
|
18
|
+
isPM: boolean;
|
|
16
19
|
};
|
|
17
20
|
export default getTimeInfoInET;
|
package/dist/index.d.ts
CHANGED
|
@@ -899,9 +899,10 @@ declare const getOrdinal: (num: number) => string;
|
|
|
899
899
|
* Get current time info in US Boston Eastern Time, independent of machine
|
|
900
900
|
* timezone
|
|
901
901
|
* @author Gabe Abrams
|
|
902
|
-
* @param [
|
|
902
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
903
903
|
* @returns object with timestamp (ms since epoch) and numbers
|
|
904
|
-
* corresponding to ET time values for year, month, day, hour, minute
|
|
904
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
|
|
905
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
905
906
|
*/
|
|
906
907
|
declare const getTimeInfoInET: (dateOrTimestamp?: number | Date | undefined) => {
|
|
907
908
|
timestamp: number;
|
|
@@ -909,7 +910,9 @@ declare const getTimeInfoInET: (dateOrTimestamp?: number | Date | undefined) =>
|
|
|
909
910
|
month: number;
|
|
910
911
|
day: number;
|
|
911
912
|
hour: number;
|
|
913
|
+
hour12: number;
|
|
912
914
|
minute: number;
|
|
915
|
+
isPM: boolean;
|
|
913
916
|
};
|
|
914
917
|
|
|
915
918
|
/**
|
package/package.json
CHANGED
|
@@ -56,15 +56,15 @@ let storedSendRequest: SendRequestFunction;
|
|
|
56
56
|
* @returns sendRequest function
|
|
57
57
|
*/
|
|
58
58
|
export const getSendRequest = async () => {
|
|
59
|
-
//
|
|
59
|
+
// Track timeout
|
|
60
60
|
let timedOut = false;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
(async () => {
|
|
62
|
+
await waitMs(5000);
|
|
63
|
+
timedOut = true;
|
|
64
|
+
})(),
|
|
65
|
+
|
|
66
|
+
// Wait for initialization
|
|
67
|
+
await initialized;
|
|
68
68
|
|
|
69
69
|
// Error if no send request function
|
|
70
70
|
if (timedOut) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current time info in local time
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
5
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
6
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
7
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
|
+
*/
|
|
9
|
+
const getLocalTimeInfo = (dateOrTimestamp?: Date | number): {
|
|
10
|
+
timestamp: number,
|
|
11
|
+
year: number,
|
|
12
|
+
month: number,
|
|
13
|
+
day: number,
|
|
14
|
+
hour: number,
|
|
15
|
+
hour12: number,
|
|
16
|
+
minute: number,
|
|
17
|
+
isPM: boolean,
|
|
18
|
+
} => {
|
|
19
|
+
// Create a time string
|
|
20
|
+
let d: Date;
|
|
21
|
+
if (!dateOrTimestamp) {
|
|
22
|
+
// Use now
|
|
23
|
+
d = new Date();
|
|
24
|
+
} else if (typeof dateOrTimestamp === 'number') {
|
|
25
|
+
// Convert to date
|
|
26
|
+
d = new Date(dateOrTimestamp);
|
|
27
|
+
} else {
|
|
28
|
+
// Already a date
|
|
29
|
+
d = dateOrTimestamp;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Create all time numbers
|
|
33
|
+
const timestamp = d.getTime();
|
|
34
|
+
const year = d.getFullYear();
|
|
35
|
+
const month = d.getMonth() + 1;
|
|
36
|
+
const day = d.getDate();
|
|
37
|
+
const hour = d.getHours();
|
|
38
|
+
const isPM = hour >= 12;
|
|
39
|
+
const hour12 = hour % 12;
|
|
40
|
+
const minute = d.getMinutes();
|
|
41
|
+
|
|
42
|
+
// Return
|
|
43
|
+
return {
|
|
44
|
+
timestamp,
|
|
45
|
+
year,
|
|
46
|
+
month,
|
|
47
|
+
day,
|
|
48
|
+
hour,
|
|
49
|
+
hour12,
|
|
50
|
+
isPM,
|
|
51
|
+
minute,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default getLocalTimeInfo;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Get current time info in US Boston Eastern Time, independent of machine
|
|
3
3
|
* timezone
|
|
4
4
|
* @author Gabe Abrams
|
|
5
|
-
* @param [
|
|
5
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
6
6
|
* @returns object with timestamp (ms since epoch) and numbers
|
|
7
|
-
* corresponding to ET time values for year, month, day, hour, minute
|
|
7
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
|
|
8
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
9
|
*/
|
|
9
10
|
const getTimeInfoInET = (dateOrTimestamp?: Date | number): {
|
|
10
11
|
timestamp: number,
|
|
@@ -12,7 +13,9 @@ const getTimeInfoInET = (dateOrTimestamp?: Date | number): {
|
|
|
12
13
|
month: number,
|
|
13
14
|
day: number,
|
|
14
15
|
hour: number,
|
|
16
|
+
hour12: number,
|
|
15
17
|
minute: number,
|
|
18
|
+
isPM: boolean,
|
|
16
19
|
} => {
|
|
17
20
|
// Create a time string
|
|
18
21
|
let d: Date;
|
|
@@ -42,13 +45,14 @@ const getTimeInfoInET = (dateOrTimestamp?: Date | number): {
|
|
|
42
45
|
const month = Number.parseInt(monthStr, 10);
|
|
43
46
|
const day = Number.parseInt(dayStr, 10);
|
|
44
47
|
const minute = Number.parseInt(minStr, 10);
|
|
45
|
-
let
|
|
48
|
+
let hour12 = Number.parseInt(hourStr, 10);
|
|
46
49
|
// Convert from am/pm to 24hr
|
|
47
50
|
const isAM = ending.toLowerCase().includes('am');
|
|
48
51
|
const isPM = !isAM;
|
|
49
|
-
|
|
52
|
+
let hour = hour12
|
|
53
|
+
if (isPM && hour12 !== 12) {
|
|
50
54
|
hour += 12;
|
|
51
|
-
} else if (isAM &&
|
|
55
|
+
} else if (isAM && hour12 === 12) {
|
|
52
56
|
hour = 0;
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -59,6 +63,8 @@ const getTimeInfoInET = (dateOrTimestamp?: Date | number): {
|
|
|
59
63
|
month,
|
|
60
64
|
day,
|
|
61
65
|
hour,
|
|
66
|
+
hour12,
|
|
67
|
+
isPM,
|
|
62
68
|
minute,
|
|
63
69
|
};
|
|
64
70
|
};
|