dce-commonkit 5.0.1 → 5.0.2
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/lib/helpers/getMondayOfWeek.d.ts +10 -0
- package/lib/helpers/getMondayOfWeek.js +39 -0
- package/lib/helpers/getMondayOfWeek.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/getMondayOfWeek.ts +41 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the start of the week (Monday) in string form given a specific timestamp.
|
|
3
|
+
* The format is MM/DD/YYYY.
|
|
4
|
+
* @author Allison Zhang
|
|
5
|
+
* @param timestamp the timestamp of a date within a week
|
|
6
|
+
* @returns string with format 'MM/DD/YYYY' of the Monday that starts the week
|
|
7
|
+
* that contains the timestamp
|
|
8
|
+
*/
|
|
9
|
+
declare const getMondayOfTimestamp: (timestamp: number) => string;
|
|
10
|
+
export default getMondayOfTimestamp;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var getTimeInfoInET_1 = __importDefault(require("./getTimeInfoInET"));
|
|
7
|
+
/**
|
|
8
|
+
* Get the start of the week (Monday) in string form given a specific timestamp.
|
|
9
|
+
* The format is MM/DD/YYYY.
|
|
10
|
+
* @author Allison Zhang
|
|
11
|
+
* @param timestamp the timestamp of a date within a week
|
|
12
|
+
* @returns string with format 'MM/DD/YYYY' of the Monday that starts the week
|
|
13
|
+
* that contains the timestamp
|
|
14
|
+
*/
|
|
15
|
+
var getMondayOfTimestamp = function (timestamp) {
|
|
16
|
+
// Get the date in ET!
|
|
17
|
+
var _a = (0, getTimeInfoInET_1.default)(timestamp), month = _a.month, day = _a.day, year = _a.year;
|
|
18
|
+
var date = new Date("".concat(month, "/").concat(day, "/").concat(year));
|
|
19
|
+
var dayOfTheWeek = date.getDay();
|
|
20
|
+
// Get the offset to the previous Monday
|
|
21
|
+
// If the day of the week is Sunda, we want the offset to be the Monday of
|
|
22
|
+
// the previous week
|
|
23
|
+
var daysPastPrevMonday = 0;
|
|
24
|
+
if (dayOfTheWeek === 0) {
|
|
25
|
+
// Handle Sunday separately: Sunday is 6 days past Monday
|
|
26
|
+
daysPastPrevMonday = 6;
|
|
27
|
+
}
|
|
28
|
+
else if (dayOfTheWeek > 1) {
|
|
29
|
+
// Tuesday - Saturday: just subtract 1 from the day of the week
|
|
30
|
+
// (dayOfTheWeek: 1 = Monday, 2 = Tuesday)
|
|
31
|
+
daysPastPrevMonday = dayOfTheWeek - 1;
|
|
32
|
+
}
|
|
33
|
+
var dayOfTheMonth = date.getDate();
|
|
34
|
+
// Get the day of the month of the previous Monday
|
|
35
|
+
date.setDate(dayOfTheMonth - daysPastPrevMonday);
|
|
36
|
+
return "".concat(date.getMonth() + 1, "/").concat(date.getDate(), "/").concat(date.getFullYear());
|
|
37
|
+
};
|
|
38
|
+
exports.default = getMondayOfTimestamp;
|
|
39
|
+
//# sourceMappingURL=getMondayOfWeek.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMondayOfWeek.js","sourceRoot":"","sources":["../../src/helpers/getMondayOfWeek.ts"],"names":[],"mappings":";;;;;AAAA,sEAAgD;AAEhD;;;;;;;GAOG;AACH,IAAM,oBAAoB,GAAG,UAAC,SAAiB;IAC7C,sBAAsB;IAChB,IAAA,KAIF,IAAA,yBAAe,EAAC,SAAS,CAAC,EAH5B,KAAK,WAAA,EACL,GAAG,SAAA,EACH,IAAI,UACwB,CAAC;IAC/B,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAG,KAAK,cAAI,GAAG,cAAI,IAAI,CAAE,CAAC,CAAC;IAEjD,IAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IACnC,wCAAwC;IAExC,0EAA0E;IAC1E,oBAAoB;IACpB,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAC3B,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACvB,yDAAyD;QACzD,kBAAkB,GAAG,CAAC,CAAC;IACzB,CAAC;SAAM,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QAC5B,+DAA+D;QAC/D,0CAA0C;QAC1C,kBAAkB,GAAG,YAAY,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,IAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACrC,kDAAkD;IAClD,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,kBAAkB,CAAC,CAAC;IACjD,OAAO,UAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,cAAI,IAAI,CAAC,OAAO,EAAE,cAAI,IAAI,CAAC,WAAW,EAAE,CAAE,CAAC;AAC1E,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import getPartOfDay from './helpers/getPartOfDay';
|
|
|
25
25
|
import stringsToHumanReadableList from './helpers/stringsToHumanReadableList';
|
|
26
26
|
import onlyKeepLetters from './helpers/onlyKeepLetters';
|
|
27
27
|
import parallelLimit from './helpers/parallelLimit';
|
|
28
|
+
import getMondayOfTimestamp from './helpers/getMondayOfWeek';
|
|
28
29
|
import getMonthName from './helpers/getMonthName';
|
|
29
30
|
import genCSV from './helpers/genCSV';
|
|
30
31
|
import extractProp from './helpers/extractProp';
|
|
@@ -69,4 +70,4 @@ import ContextFilterState from './types/LogReviewerFilterState/ContextFilterStat
|
|
|
69
70
|
import TagFilterState from './types/LogReviewerFilterState/TagFilterState';
|
|
70
71
|
import ActionErrorFilterState from './types/LogReviewerFilterState/ActionErrorFilterState';
|
|
71
72
|
import AdvancedFilterState from './types/LogReviewerFilterState/AdvancedFilterState';
|
|
72
|
-
export { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, CommonKitErrorCode, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, LogMetadataContextMap, LogMetadataTargetMap, LogReviewerFilterState, DateFilterState, ContextFilterState, TagFilterState, ActionErrorFilterState, AdvancedFilterState, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, };
|
|
73
|
+
export { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, CommonKitErrorCode, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, LogMetadataContextMap, LogMetadataTargetMap, LogReviewerFilterState, DateFilterState, ContextFilterState, TagFilterState, ActionErrorFilterState, AdvancedFilterState, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMondayOfTimestamp, getMonthName, genCSV, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, };
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.spaceAtCapitals = exports.getTimestampFromTimeInfoInET = exports.cloneDeep = exports.getWordCount = exports.shuffleArray = exports.capitalize = exports.someAsync = void 0;
|
|
6
|
+
exports.forEachAsync = exports.filterAsync = exports.everyAsync = exports.prefixWithAOrAn = exports.idify = exports.getLocalTimeInfo = exports.validateString = exports.validatePhoneNumber = exports.validateEmail = exports.genCommaList = exports.compareArraysByProp = exports.extractProp = exports.genCSV = exports.getMonthName = exports.getMondayOfTimestamp = exports.parallelLimit = exports.onlyKeepLetters = exports.stringsToHumanReadableList = exports.getPartOfDay = exports.getHumanReadableDate = exports.startMinWait = exports.getTimeInfoInET = exports.getOrdinal = exports.waitMs = exports.sum = exports.roundToNumDecimals = exports.padZerosLeft = exports.padDecimalZeros = exports.forceNumIntoBounds = exports.floorToNumDecimals = exports.ceilToNumDecimals = exports.avg = exports.abbreviate = exports.LogLevel = exports.LogBuiltInMetadata = exports.LogAction = exports.LogSource = exports.LogType = exports.DayOfWeek = exports.ParamType = exports.CommonKitErrorCode = exports.SELECT_ADMIN_CHECK_ROUTE = exports.LOG_REVIEW_GET_LOGS_ROUTE = exports.LOG_REVIEW_STATUS_ROUTE = exports.LOG_ROUTE_PATH = exports.LOG_REVIEW_ROUTE_PATH_PREFIX = exports.DAY_IN_MS = exports.HOUR_IN_MS = exports.MINUTE_IN_MS = exports.ErrorWithCode = void 0;
|
|
7
|
+
exports.spaceAtCapitals = exports.getTimestampFromTimeInfoInET = exports.cloneDeep = exports.getWordCount = exports.shuffleArray = exports.capitalize = exports.someAsync = exports.mapAsync = void 0;
|
|
8
8
|
// Import errors
|
|
9
9
|
var ErrorWithCode_1 = __importDefault(require("./errors/ErrorWithCode"));
|
|
10
10
|
exports.ErrorWithCode = ErrorWithCode_1.default;
|
|
@@ -62,6 +62,8 @@ var onlyKeepLetters_1 = __importDefault(require("./helpers/onlyKeepLetters"));
|
|
|
62
62
|
exports.onlyKeepLetters = onlyKeepLetters_1.default;
|
|
63
63
|
var parallelLimit_1 = __importDefault(require("./helpers/parallelLimit"));
|
|
64
64
|
exports.parallelLimit = parallelLimit_1.default;
|
|
65
|
+
var getMondayOfWeek_1 = __importDefault(require("./helpers/getMondayOfWeek"));
|
|
66
|
+
exports.getMondayOfTimestamp = getMondayOfWeek_1.default;
|
|
65
67
|
var getMonthName_1 = __importDefault(require("./helpers/getMonthName"));
|
|
66
68
|
exports.getMonthName = getMonthName_1.default;
|
|
67
69
|
var genCSV_1 = __importDefault(require("./helpers/genCSV"));
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,gBAAgB;AAChB,yEAAmD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,gBAAgB;AAChB,yEAAmD;AAkFjD,wBAlFK,uBAAa,CAkFL;AAhFf,mBAAmB;AACnB,0EAAoD;AAiFlD,uBAjFK,sB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CL;AArCT,gEAA0C;AAsCxC,oBAtCK,mBAAS,CAsCL;AArCX,gEAA0C;AAsCxC,oBAtCK,mBAAS,CAsCL;AArCX,kFAA4D;AAsC1D,6BAtCK,4BAAkB,CAsCL;AAhCpB,8DAAwC;AAsCtC,mBAtCK,kBAAQ,CAsCL;AArCV,kFAA4D;AAwB1D,6BAxBK,4BAAkB,CAwBL"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import getTimeInfoInET from './getTimeInfoInET';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the start of the week (Monday) in string form given a specific timestamp.
|
|
5
|
+
* The format is MM/DD/YYYY.
|
|
6
|
+
* @author Allison Zhang
|
|
7
|
+
* @param timestamp the timestamp of a date within a week
|
|
8
|
+
* @returns string with format 'MM/DD/YYYY' of the Monday that starts the week
|
|
9
|
+
* that contains the timestamp
|
|
10
|
+
*/
|
|
11
|
+
const getMondayOfTimestamp = (timestamp: number): string => {
|
|
12
|
+
// Get the date in ET!
|
|
13
|
+
const {
|
|
14
|
+
month,
|
|
15
|
+
day,
|
|
16
|
+
year,
|
|
17
|
+
} = getTimeInfoInET(timestamp);
|
|
18
|
+
const date = new Date(`${month}/${day}/${year}`);
|
|
19
|
+
|
|
20
|
+
const dayOfTheWeek = date.getDay();
|
|
21
|
+
// Get the offset to the previous Monday
|
|
22
|
+
|
|
23
|
+
// If the day of the week is Sunda, we want the offset to be the Monday of
|
|
24
|
+
// the previous week
|
|
25
|
+
let daysPastPrevMonday = 0;
|
|
26
|
+
if (dayOfTheWeek === 0) {
|
|
27
|
+
// Handle Sunday separately: Sunday is 6 days past Monday
|
|
28
|
+
daysPastPrevMonday = 6;
|
|
29
|
+
} else if (dayOfTheWeek > 1) {
|
|
30
|
+
// Tuesday - Saturday: just subtract 1 from the day of the week
|
|
31
|
+
// (dayOfTheWeek: 1 = Monday, 2 = Tuesday)
|
|
32
|
+
daysPastPrevMonday = dayOfTheWeek - 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const dayOfTheMonth = date.getDate();
|
|
36
|
+
// Get the day of the month of the previous Monday
|
|
37
|
+
date.setDate(dayOfTheMonth - daysPastPrevMonday);
|
|
38
|
+
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default getMondayOfTimestamp;
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ import getPartOfDay from './helpers/getPartOfDay';
|
|
|
30
30
|
import stringsToHumanReadableList from './helpers/stringsToHumanReadableList';
|
|
31
31
|
import onlyKeepLetters from './helpers/onlyKeepLetters';
|
|
32
32
|
import parallelLimit from './helpers/parallelLimit';
|
|
33
|
+
import getMondayOfTimestamp from './helpers/getMondayOfWeek';
|
|
33
34
|
import getMonthName from './helpers/getMonthName';
|
|
34
35
|
import genCSV from './helpers/genCSV';
|
|
35
36
|
import extractProp from './helpers/extractProp';
|
|
@@ -132,6 +133,7 @@ export {
|
|
|
132
133
|
stringsToHumanReadableList,
|
|
133
134
|
onlyKeepLetters,
|
|
134
135
|
parallelLimit,
|
|
136
|
+
getMondayOfTimestamp,
|
|
135
137
|
getMonthName,
|
|
136
138
|
genCSV,
|
|
137
139
|
extractProp,
|