@8ms/helpers 1.0.12 → 1.0.13

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.
@@ -1,8 +1,9 @@
1
1
  import { DateType } from './types';
2
2
  /**
3
- * Return the maximum date (up to Yesterday) as a formatted string.
3
+ * If a given date is beyond the maximum, return the maximum.
4
4
  */
5
- declare const getMax: ({ input }: {
5
+ declare const getMax: ({ input, max }: {
6
6
  input: DateType;
7
+ max: DateType;
7
8
  }) => Date;
8
9
  export default getMax;
@@ -5,15 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var isAfter_1 = __importDefault(require("date-fns/isAfter"));
7
7
  var getDate_1 = __importDefault(require("./getDate"));
8
- var getYesterday_1 = __importDefault(require("./getYesterday"));
9
8
  /**
10
- * Return the maximum date (up to Yesterday) as a formatted string.
9
+ * If a given date is beyond the maximum, return the maximum.
11
10
  */
12
11
  var getMax = function (_a) {
13
- var input = _a.input;
14
- var yesterday = (0, getYesterday_1.default)();
15
- var parsed = (0, getDate_1.default)({ input: input });
16
- var max = (0, isAfter_1.default)(parsed, yesterday) ? yesterday : parsed;
17
- return max;
12
+ var input = _a.input, max = _a.max;
13
+ var parsedMax = (0, getDate_1.default)({ input: max });
14
+ var parsedInput = (0, getDate_1.default)({ input: input });
15
+ return (0, isAfter_1.default)(parsedInput, parsedMax) ? parsedMax : parsedInput;
18
16
  };
19
17
  exports.default = getMax;
@@ -0,0 +1,9 @@
1
+ import { DateType } from './types';
2
+ /**
3
+ * If a given date is before the minimum, return the minimum.
4
+ */
5
+ declare const getMin: ({ input, min }: {
6
+ input: DateType;
7
+ min: DateType;
8
+ }) => Date;
9
+ export default getMin;
@@ -0,0 +1,17 @@
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 isBefore_1 = __importDefault(require("date-fns/isBefore"));
7
+ var getDate_1 = __importDefault(require("./getDate"));
8
+ /**
9
+ * If a given date is before the minimum, return the minimum.
10
+ */
11
+ var getMin = function (_a) {
12
+ var input = _a.input, min = _a.min;
13
+ var parsedMin = (0, getDate_1.default)({ input: min });
14
+ var parsedInput = (0, getDate_1.default)({ input: input });
15
+ return (0, isBefore_1.default)(parsedInput, parsedMin) ? parsedMin : parsedInput;
16
+ };
17
+ exports.default = getMin;
@@ -7,6 +7,7 @@ import getFinancialYear from './getFinancialYear';
7
7
  import getFinancialYearToDate from './getFinancialYearToDate';
8
8
  import getLastWeek from './getLastWeek';
9
9
  import getMax from './getMax';
10
+ import getMin from './getMin';
10
11
  import getMonday from './getMonday';
11
12
  import getNumber from './getNumber';
12
13
  import getPredefinedTimeframe from './getPredefinedTimeframe';
@@ -21,4 +22,4 @@ import isThisWeek from './isThisWeek';
21
22
  import parseExcelDate from './parseExcelDate';
22
23
  import { DateType, FinancialYearType, FinancialYearWeekType, TimeframePredefinedType, TimeframeType } from './types';
23
24
  export type { DateType, FinancialYearType, FinancialYearWeekType, TimeframeType, TimeframePredefinedType, };
24
- export { Duration, DurationComparison, Timeframe, TimeframePredefined, format, getDate, getDurationHours, getDurationMinutes, getFinancialYear, getFinancialYearToDate, getLastWeek, getMax, getMonday, getNumber, getPredefinedTimeframe, getSunday, getThisWeek, getToday, getTwoWeeksAgo, getYesterday, isDateValid, isLastWeek, isThisWeek, parseExcelDate, };
25
+ export { Duration, DurationComparison, Timeframe, TimeframePredefined, format, getDate, getDurationHours, getDurationMinutes, getFinancialYear, getFinancialYearToDate, getLastWeek, getMax, getMin, getMonday, getNumber, getPredefinedTimeframe, getSunday, getThisWeek, getToday, getTwoWeeksAgo, getYesterday, isDateValid, isLastWeek, isThisWeek, parseExcelDate, };
@@ -3,7 +3,7 @@ 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.parseExcelDate = exports.isThisWeek = exports.isLastWeek = exports.isDateValid = exports.getYesterday = exports.getTwoWeeksAgo = exports.getToday = exports.getThisWeek = exports.getSunday = exports.getPredefinedTimeframe = exports.getNumber = exports.getMonday = exports.getMax = exports.getLastWeek = exports.getFinancialYearToDate = exports.getFinancialYear = exports.getDurationMinutes = exports.getDurationHours = exports.getDate = exports.format = exports.TimeframePredefined = exports.Timeframe = exports.DurationComparison = exports.Duration = void 0;
6
+ exports.parseExcelDate = exports.isThisWeek = exports.isLastWeek = exports.isDateValid = exports.getYesterday = exports.getTwoWeeksAgo = exports.getToday = exports.getThisWeek = exports.getSunday = exports.getPredefinedTimeframe = exports.getNumber = exports.getMonday = exports.getMin = exports.getMax = exports.getLastWeek = exports.getFinancialYearToDate = exports.getFinancialYear = exports.getDurationMinutes = exports.getDurationHours = exports.getDate = exports.format = exports.TimeframePredefined = exports.Timeframe = exports.DurationComparison = exports.Duration = void 0;
7
7
  var constants_1 = require("./constants");
8
8
  Object.defineProperty(exports, "Duration", { enumerable: true, get: function () { return constants_1.Duration; } });
9
9
  Object.defineProperty(exports, "DurationComparison", { enumerable: true, get: function () { return constants_1.DurationComparison; } });
@@ -25,6 +25,8 @@ var getLastWeek_1 = __importDefault(require("./getLastWeek"));
25
25
  exports.getLastWeek = getLastWeek_1.default;
26
26
  var getMax_1 = __importDefault(require("./getMax"));
27
27
  exports.getMax = getMax_1.default;
28
+ var getMin_1 = __importDefault(require("./getMin"));
29
+ exports.getMin = getMin_1.default;
28
30
  var getMonday_1 = __importDefault(require("./getMonday"));
29
31
  exports.getMonday = getMonday_1.default;
30
32
  var getNumber_1 = __importDefault(require("./getNumber"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"