dce-reactkit 3.3.3-beta.2 → 3.3.5
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 +55 -5
- 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/cjs/types/index.d.ts +2 -1
- package/dist/esm/index.js +55 -6
- 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/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +25 -3
- package/package.json +1 -1
- package/src/helpers/getLocalTimeInfo.tsx +55 -0
- package/src/helpers/getTimeInfoInET.tsx +11 -5
- package/src/index.ts +2 -0
|
@@ -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;
|
|
@@ -54,6 +54,7 @@ import canReviewLogs from './helpers/canReviewLogs';
|
|
|
54
54
|
import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
55
55
|
import extractProp from './helpers/extractProp';
|
|
56
56
|
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
57
|
+
import getLocalTimeInfo from './helpers/getLocalTimeInfo';
|
|
57
58
|
import ModalButtonType from './types/ModalButtonType';
|
|
58
59
|
import ModalSize from './types/ModalSize';
|
|
59
60
|
import ModalType from './types/ModalType';
|
|
@@ -69,4 +70,4 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
|
69
70
|
import LogMetadataType from './types/LogMetadataType';
|
|
70
71
|
import IntelliTableColumn from './types/IntelliTableColumn';
|
|
71
72
|
import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
72
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
|
|
73
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
|
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
|
/**
|
|
@@ -1063,6 +1066,25 @@ declare const extractProp: (arr: any[], prop: string) => any[];
|
|
|
1063
1066
|
*/
|
|
1064
1067
|
declare const compareArraysByProp: (a: any[], b: any[], prop: string) => boolean;
|
|
1065
1068
|
|
|
1069
|
+
/**
|
|
1070
|
+
* Get current time info in local time
|
|
1071
|
+
* @author Gabe Abrams
|
|
1072
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
1073
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
1074
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
1075
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
1076
|
+
*/
|
|
1077
|
+
declare const getLocalTimeInfo: (dateOrTimestamp?: number | Date | undefined) => {
|
|
1078
|
+
timestamp: number;
|
|
1079
|
+
year: number;
|
|
1080
|
+
month: number;
|
|
1081
|
+
day: number;
|
|
1082
|
+
hour: number;
|
|
1083
|
+
hour12: number;
|
|
1084
|
+
minute: number;
|
|
1085
|
+
isPM: boolean;
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1066
1088
|
/**
|
|
1067
1089
|
* List of error codes built into the react kit
|
|
1068
1090
|
* @author Gabe Abrams
|
|
@@ -1113,4 +1135,4 @@ declare const LogBuiltInMetadata: {
|
|
|
1113
1135
|
};
|
|
1114
1136
|
};
|
|
1115
1137
|
|
|
1116
|
-
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
1138
|
+
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
package/package.json
CHANGED
|
@@ -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
|
};
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ import canReviewLogs from './helpers/canReviewLogs';
|
|
|
63
63
|
import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
64
64
|
import extractProp from './helpers/extractProp';
|
|
65
65
|
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
66
|
+
import getLocalTimeInfo from './helpers/getLocalTimeInfo';
|
|
66
67
|
|
|
67
68
|
// Import types
|
|
68
69
|
import ModalButtonType from './types/ModalButtonType';
|
|
@@ -142,6 +143,7 @@ export {
|
|
|
142
143
|
isMobileOrTablet,
|
|
143
144
|
extractProp,
|
|
144
145
|
compareArraysByProp,
|
|
146
|
+
getLocalTimeInfo,
|
|
145
147
|
// Client helpers
|
|
146
148
|
initClient,
|
|
147
149
|
visitServerEndpoint,
|