dce-commonkit 5.0.1 → 5.0.3

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
+ import DateInfo from '../types/DateInfo';
2
+ /**
3
+ * Convert dateKey in MM/DD/YYYY format to DateInfo object
4
+ * @author Gardenia Liu
5
+ * @param dateKey - Date string in MM/DD/YYYY format (e.g., "7/19/2025")
6
+ * @returns DateInfo object or null if parsing fails
7
+ */
8
+ declare const convertDateKeyToDateInfo: (dateKey: string) => DateInfo | null;
9
+ export default convertDateKeyToDateInfo;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Convert dateKey in MM/DD/YYYY format to DateInfo object
5
+ * @author Gardenia Liu
6
+ * @param dateKey - Date string in MM/DD/YYYY format (e.g., "7/19/2025")
7
+ * @returns DateInfo object or null if parsing fails
8
+ */
9
+ var convertDateKeyToDateInfo = function (dateKey) {
10
+ var _a = dateKey.split('/'), monthStr = _a[0], dayStr = _a[1], yearStr = _a[2];
11
+ var month = Number.parseInt(monthStr, 10);
12
+ var day = Number.parseInt(dayStr, 10);
13
+ var year = Number.parseInt(yearStr, 10);
14
+ // Return DateInfo if parsing was successful (no NaN values)
15
+ if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
16
+ return {
17
+ year: year,
18
+ month: month,
19
+ day: day,
20
+ };
21
+ }
22
+ return null;
23
+ };
24
+ exports.default = convertDateKeyToDateInfo;
25
+ //# sourceMappingURL=convertDateKeyToDateInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertDateKeyToDateInfo.js","sourceRoot":"","sources":["../../src/helpers/convertDateKeyToDateInfo.ts"],"names":[],"mappings":";;AAGA;;;;;GAKG;AACH,IAAM,wBAAwB,GAAG,UAAC,OAAe;IACzC,IAAA,KAA8B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAA/C,QAAQ,QAAA,EAAE,MAAM,QAAA,EAAE,OAAO,QAAsB,CAAC;IAEvD,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxC,IAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE1C,4DAA4D;IAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACtE,OAAO;YACL,IAAI,MAAA;YACJ,KAAK,OAAA;YACL,GAAG,KAAA;SACJ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC"}
@@ -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';
@@ -47,6 +48,7 @@ import getWordCount from './helpers/getWordCount';
47
48
  import cloneDeep from './helpers/cloneDeep';
48
49
  import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
49
50
  import spaceAtCapitals from './helpers/spaceAtCapitals';
51
+ import convertDateKeyToDateInfo from './helpers/convertDateKeyToDateInfo';
50
52
  import ParamType from './types/ParamType';
51
53
  import DayOfWeek from './types/DayOfWeek';
52
54
  import Log from './types/Log';
@@ -69,4 +71,4 @@ import ContextFilterState from './types/LogReviewerFilterState/ContextFilterStat
69
71
  import TagFilterState from './types/LogReviewerFilterState/TagFilterState';
70
72
  import ActionErrorFilterState from './types/LogReviewerFilterState/ActionErrorFilterState';
71
73
  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, };
74
+ 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, convertDateKeyToDateInfo, 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.mapAsync = 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.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 = void 0;
6
+ 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.convertDateKeyToDateInfo = 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 = exports.forEachAsync = 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"));
@@ -106,6 +108,8 @@ var getTimestampFromTimeInfoInET_1 = __importDefault(require("./helpers/getTimes
106
108
  exports.getTimestampFromTimeInfoInET = getTimestampFromTimeInfoInET_1.default;
107
109
  var spaceAtCapitals_1 = __importDefault(require("./helpers/spaceAtCapitals"));
108
110
  exports.spaceAtCapitals = spaceAtCapitals_1.default;
111
+ var convertDateKeyToDateInfo_1 = __importDefault(require("./helpers/convertDateKeyToDateInfo"));
112
+ exports.convertDateKeyToDateInfo = convertDateKeyToDateInfo_1.default;
109
113
  // Import types
110
114
  var ParamType_1 = __importDefault(require("./types/ParamType"));
111
115
  exports.ParamType = ParamType_1.default;
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;AAiFjD,wBAjFK,uBAAa,CAiFL;AA/Ef,mBAAmB;AACnB,0EAAoD;AAgFlD,uBAhFK,sBAAY,CAgFL;AA/Ed,sEAAgD;AAgF9C,qBAhFK,oBAAU,CAgFL;AA/EZ,oEAA8C;AAgF5C,oBAhFK,mBAAS,CAgFL;AA/EX,0GAAoF;AAgFlF,uCAhFK,sCAA4B,CAgFL;AA/E9B,8EAAwD;AAgFtD,yBAhFK,wBAAc,CAgFL;AA/EhB,gGAA0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CAAwB,CA2EL;AAzE1B,eAAe;AACf,gEAA0C;AAsCxC,oBAtCK,mBAAS,CAsCL;AArCX,gEAA0C;AAsCxC,oBAtCK,mBAAS,CAsCL;AApCX,4DAAsC;AAsCpC,kBAtCK,iBAAO,CAsCL;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"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Bundle of all date information for an attendance record
3
+ * @author Gabe Abrams
4
+ */
5
+ type DateInfo = {
6
+ year: number;
7
+ month: number;
8
+ day: number;
9
+ };
10
+ export default DateInfo;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=DateInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateInfo.js","sourceRoot":"","sources":["../../src/types/DateInfo.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-commonkit",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Common helpers, constants, and other resources that are shared between dce-reactkit and dce-expresskit",
5
5
  "keywords": [
6
6
  "DCE",
@@ -0,0 +1,29 @@
1
+ // import types
2
+ import DateInfo from '../types/DateInfo';
3
+
4
+ /**
5
+ * Convert dateKey in MM/DD/YYYY format to DateInfo object
6
+ * @author Gardenia Liu
7
+ * @param dateKey - Date string in MM/DD/YYYY format (e.g., "7/19/2025")
8
+ * @returns DateInfo object or null if parsing fails
9
+ */
10
+ const convertDateKeyToDateInfo = (dateKey: string): DateInfo | null => {
11
+ const [monthStr, dayStr, yearStr] = dateKey.split('/');
12
+
13
+ const month = Number.parseInt(monthStr, 10);
14
+ const day = Number.parseInt(dayStr, 10);
15
+ const year = Number.parseInt(yearStr, 10);
16
+
17
+ // Return DateInfo if parsing was successful (no NaN values)
18
+ if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
19
+ return {
20
+ year,
21
+ month,
22
+ day,
23
+ };
24
+ }
25
+
26
+ return null;
27
+ };
28
+
29
+ export default convertDateKeyToDateInfo;
@@ -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';
@@ -52,6 +53,7 @@ import getWordCount from './helpers/getWordCount';
52
53
  import cloneDeep from './helpers/cloneDeep';
53
54
  import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
54
55
  import spaceAtCapitals from './helpers/spaceAtCapitals';
56
+ import convertDateKeyToDateInfo from './helpers/convertDateKeyToDateInfo';
55
57
 
56
58
  // Import types
57
59
  import ParamType from './types/ParamType';
@@ -126,12 +128,14 @@ export {
126
128
  waitMs,
127
129
  getOrdinal,
128
130
  getTimeInfoInET,
131
+ convertDateKeyToDateInfo,
129
132
  startMinWait,
130
133
  getHumanReadableDate,
131
134
  getPartOfDay,
132
135
  stringsToHumanReadableList,
133
136
  onlyKeepLetters,
134
137
  parallelLimit,
138
+ getMondayOfTimestamp,
135
139
  getMonthName,
136
140
  genCSV,
137
141
  extractProp,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Bundle of all date information for an attendance record
3
+ * @author Gabe Abrams
4
+ */
5
+ type DateInfo = {
6
+ // Year
7
+ year: number,
8
+ // Month
9
+ month: number,
10
+ // Day of month
11
+ day: number,
12
+ };
13
+
14
+ export default DateInfo;