@dereekb/date 11.0.0 → 11.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/index.cjs.js
CHANGED
|
@@ -7830,16 +7830,19 @@ function nowInterval(period) {
|
|
|
7830
7830
|
*/
|
|
7831
7831
|
class LimitDateTimeInstance {
|
|
7832
7832
|
constructor(config = {}) {
|
|
7833
|
-
this.
|
|
7834
|
-
this.
|
|
7833
|
+
this._config = void 0;
|
|
7834
|
+
this._config = config;
|
|
7835
|
+
}
|
|
7836
|
+
get config() {
|
|
7837
|
+
return this._config;
|
|
7835
7838
|
}
|
|
7836
7839
|
get instant() {
|
|
7837
|
-
return this.
|
|
7840
|
+
return this._config.instant || 'now';
|
|
7838
7841
|
}
|
|
7839
7842
|
get minimumMinutesIntoFuture() {
|
|
7840
7843
|
const {
|
|
7841
7844
|
limits = {}
|
|
7842
|
-
} = this.
|
|
7845
|
+
} = this._config;
|
|
7843
7846
|
const {
|
|
7844
7847
|
future
|
|
7845
7848
|
} = limits;
|
|
@@ -7860,7 +7863,7 @@ class LimitDateTimeInstance {
|
|
|
7860
7863
|
const {
|
|
7861
7864
|
instant = new Date(),
|
|
7862
7865
|
limits = {}
|
|
7863
|
-
} = this.
|
|
7866
|
+
} = this._config;
|
|
7864
7867
|
const {
|
|
7865
7868
|
isFuture,
|
|
7866
7869
|
future,
|
|
@@ -7881,7 +7884,7 @@ class LimitDateTimeInstance {
|
|
|
7881
7884
|
const {
|
|
7882
7885
|
instant = new Date(),
|
|
7883
7886
|
limits = {}
|
|
7884
|
-
} = this.
|
|
7887
|
+
} = this._config;
|
|
7885
7888
|
const {
|
|
7886
7889
|
isPast,
|
|
7887
7890
|
max
|
|
@@ -7902,7 +7905,7 @@ class LimitDateTimeInstance {
|
|
|
7902
7905
|
dateRange() {
|
|
7903
7906
|
const {
|
|
7904
7907
|
instant = new Date()
|
|
7905
|
-
} = this.
|
|
7908
|
+
} = this._config;
|
|
7906
7909
|
return this.dateRangeForInstant(instant);
|
|
7907
7910
|
}
|
|
7908
7911
|
dateRangeForInstant(instant) {
|
|
@@ -7922,10 +7925,10 @@ class LimitDateTimeInstance {
|
|
|
7922
7925
|
let result = date;
|
|
7923
7926
|
const dateRange = this.dateRange();
|
|
7924
7927
|
result = clampDateToDateRange(date, dateRange);
|
|
7925
|
-
if (this.
|
|
7926
|
-
var _this$
|
|
7927
|
-
result = takeNextUpcomingTime(result, (_this$
|
|
7928
|
-
} else if (this.
|
|
7928
|
+
if (this._config.takeNextUpcomingTime) {
|
|
7929
|
+
var _this$_config$roundDo;
|
|
7930
|
+
result = takeNextUpcomingTime(result, (_this$_config$roundDo = this._config.roundDownToMinute) != null ? _this$_config$roundDo : false);
|
|
7931
|
+
} else if (this._config.roundDownToMinute) {
|
|
7929
7932
|
result = roundDownToMinute(result);
|
|
7930
7933
|
}
|
|
7931
7934
|
return result;
|
|
@@ -7946,17 +7949,20 @@ function limitDateTimeInstance(config) {
|
|
|
7946
7949
|
class DateTimeMinuteInstance {
|
|
7947
7950
|
constructor(config = {}, dateOverride) {
|
|
7948
7951
|
var _config$step;
|
|
7949
|
-
this.
|
|
7952
|
+
this._config = void 0;
|
|
7950
7953
|
this._date = void 0;
|
|
7951
7954
|
this._step = void 0;
|
|
7952
7955
|
this._limit = void 0;
|
|
7953
7956
|
this._dateFilter = void 0;
|
|
7954
|
-
this.
|
|
7957
|
+
this._config = config;
|
|
7955
7958
|
this._date = (dateOverride == undefined ? config.date : dateOverride) || new Date();
|
|
7956
7959
|
this._step = (_config$step = config.step) != null ? _config$step : 1;
|
|
7957
7960
|
this._limit = new LimitDateTimeInstance(config);
|
|
7958
7961
|
this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
|
|
7959
7962
|
}
|
|
7963
|
+
get config() {
|
|
7964
|
+
return this._config;
|
|
7965
|
+
}
|
|
7960
7966
|
get date() {
|
|
7961
7967
|
return this._date;
|
|
7962
7968
|
}
|
|
@@ -8147,8 +8153,8 @@ class DateTimeMinuteInstance {
|
|
|
8147
8153
|
return this._takeMaximumBoundedDate(this._takeMinimumBoundedDate(date));
|
|
8148
8154
|
}
|
|
8149
8155
|
_takeMinimumBoundedDate(date = this.date) {
|
|
8150
|
-
var _this$
|
|
8151
|
-
if (((_this$
|
|
8156
|
+
var _this$_config$behavio;
|
|
8157
|
+
if (((_this$_config$behavio = this._config.behavior) == null ? void 0 : _this$_config$behavio.capToMinLimit) !== false) {
|
|
8152
8158
|
const min = dateFromLogicalDate(this._limit.min);
|
|
8153
8159
|
if (min && dateFns.isBefore(date, min)) {
|
|
8154
8160
|
date = min;
|
|
@@ -8157,8 +8163,8 @@ class DateTimeMinuteInstance {
|
|
|
8157
8163
|
return date;
|
|
8158
8164
|
}
|
|
8159
8165
|
_takeMaximumBoundedDate(date = this.date) {
|
|
8160
|
-
var _this$
|
|
8161
|
-
if (((_this$
|
|
8166
|
+
var _this$_config$behavio2;
|
|
8167
|
+
if (((_this$_config$behavio2 = this._config.behavior) == null ? void 0 : _this$_config$behavio2.capToMaxLimit) !== false) {
|
|
8162
8168
|
const max = dateFromLogicalDate(this._limit.max);
|
|
8163
8169
|
if (max && dateFns.isAfter(date, max)) {
|
|
8164
8170
|
date = max;
|
|
@@ -9075,9 +9081,12 @@ class BaseRRuleIter {
|
|
|
9075
9081
|
class LastIterResult extends BaseRRuleIter {
|
|
9076
9082
|
constructor(maxIterationsAllowed = DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED) {
|
|
9077
9083
|
super();
|
|
9078
|
-
this.
|
|
9084
|
+
this._maxIterationsAllowed = void 0;
|
|
9079
9085
|
this.maxDate = maxFutureDate();
|
|
9080
|
-
this.
|
|
9086
|
+
this._maxIterationsAllowed = maxIterationsAllowed;
|
|
9087
|
+
}
|
|
9088
|
+
get maxIterationsAllowed() {
|
|
9089
|
+
return this._maxIterationsAllowed;
|
|
9081
9090
|
}
|
|
9082
9091
|
accept(date) {
|
|
9083
9092
|
++this.total;
|
|
@@ -9086,7 +9095,7 @@ class LastIterResult extends BaseRRuleIter {
|
|
|
9086
9095
|
return false;
|
|
9087
9096
|
} else {
|
|
9088
9097
|
this.add(date);
|
|
9089
|
-
const maxIterationReached = this.total >= this.
|
|
9098
|
+
const maxIterationReached = this.total >= this._maxIterationsAllowed;
|
|
9090
9099
|
return !maxIterationReached;
|
|
9091
9100
|
}
|
|
9092
9101
|
}
|
|
@@ -9095,7 +9104,7 @@ class LastIterResult extends BaseRRuleIter {
|
|
|
9095
9104
|
return true;
|
|
9096
9105
|
}
|
|
9097
9106
|
clone() {
|
|
9098
|
-
return new LastIterResult(this.
|
|
9107
|
+
return new LastIterResult(this._maxIterationsAllowed);
|
|
9099
9108
|
}
|
|
9100
9109
|
}
|
|
9101
9110
|
class NextIterResult extends BaseRRuleIter {
|
package/index.esm.js
CHANGED
|
@@ -8755,15 +8755,19 @@ function nowInterval(period) {
|
|
|
8755
8755
|
*/
|
|
8756
8756
|
class LimitDateTimeInstance {
|
|
8757
8757
|
constructor(config = {}) {
|
|
8758
|
-
this.
|
|
8758
|
+
this._config = void 0;
|
|
8759
|
+
this._config = config;
|
|
8760
|
+
}
|
|
8761
|
+
get config() {
|
|
8762
|
+
return this._config;
|
|
8759
8763
|
}
|
|
8760
8764
|
get instant() {
|
|
8761
|
-
return this.
|
|
8765
|
+
return this._config.instant || 'now';
|
|
8762
8766
|
}
|
|
8763
8767
|
get minimumMinutesIntoFuture() {
|
|
8764
8768
|
const {
|
|
8765
8769
|
limits = {}
|
|
8766
|
-
} = this.
|
|
8770
|
+
} = this._config;
|
|
8767
8771
|
const {
|
|
8768
8772
|
future
|
|
8769
8773
|
} = limits;
|
|
@@ -8784,7 +8788,7 @@ class LimitDateTimeInstance {
|
|
|
8784
8788
|
const {
|
|
8785
8789
|
instant = new Date(),
|
|
8786
8790
|
limits = {}
|
|
8787
|
-
} = this.
|
|
8791
|
+
} = this._config;
|
|
8788
8792
|
const {
|
|
8789
8793
|
isFuture,
|
|
8790
8794
|
future,
|
|
@@ -8805,7 +8809,7 @@ class LimitDateTimeInstance {
|
|
|
8805
8809
|
const {
|
|
8806
8810
|
instant = new Date(),
|
|
8807
8811
|
limits = {}
|
|
8808
|
-
} = this.
|
|
8812
|
+
} = this._config;
|
|
8809
8813
|
const {
|
|
8810
8814
|
isPast,
|
|
8811
8815
|
max
|
|
@@ -8827,7 +8831,7 @@ class LimitDateTimeInstance {
|
|
|
8827
8831
|
dateRange() {
|
|
8828
8832
|
const {
|
|
8829
8833
|
instant = new Date()
|
|
8830
|
-
} = this.
|
|
8834
|
+
} = this._config;
|
|
8831
8835
|
return this.dateRangeForInstant(instant);
|
|
8832
8836
|
}
|
|
8833
8837
|
dateRangeForInstant(instant) {
|
|
@@ -8848,10 +8852,10 @@ class LimitDateTimeInstance {
|
|
|
8848
8852
|
let result = date;
|
|
8849
8853
|
const dateRange = this.dateRange();
|
|
8850
8854
|
result = clampDateToDateRange(date, dateRange);
|
|
8851
|
-
if (this.
|
|
8852
|
-
var _this$
|
|
8853
|
-
result = takeNextUpcomingTime(result, (_this$
|
|
8854
|
-
} else if (this.
|
|
8855
|
+
if (this._config.takeNextUpcomingTime) {
|
|
8856
|
+
var _this$_config$roundDo;
|
|
8857
|
+
result = takeNextUpcomingTime(result, (_this$_config$roundDo = this._config.roundDownToMinute) != null ? _this$_config$roundDo : false);
|
|
8858
|
+
} else if (this._config.roundDownToMinute) {
|
|
8855
8859
|
result = roundDownToMinute(result);
|
|
8856
8860
|
}
|
|
8857
8861
|
return result;
|
|
@@ -8876,16 +8880,20 @@ function limitDateTimeInstance(config) {
|
|
|
8876
8880
|
class DateTimeMinuteInstance {
|
|
8877
8881
|
constructor(config = {}, dateOverride) {
|
|
8878
8882
|
var _config$step;
|
|
8879
|
-
this.
|
|
8883
|
+
this._config = void 0;
|
|
8880
8884
|
this._date = void 0;
|
|
8881
8885
|
this._step = void 0;
|
|
8882
8886
|
this._limit = void 0;
|
|
8883
8887
|
this._dateFilter = void 0;
|
|
8888
|
+
this._config = config;
|
|
8884
8889
|
this._date = (dateOverride == undefined ? config.date : dateOverride) || new Date();
|
|
8885
8890
|
this._step = (_config$step = config.step) != null ? _config$step : 1;
|
|
8886
8891
|
this._limit = new LimitDateTimeInstance(config);
|
|
8887
8892
|
this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
|
|
8888
8893
|
}
|
|
8894
|
+
get config() {
|
|
8895
|
+
return this._config;
|
|
8896
|
+
}
|
|
8889
8897
|
get date() {
|
|
8890
8898
|
return this._date;
|
|
8891
8899
|
}
|
|
@@ -9085,8 +9093,8 @@ class DateTimeMinuteInstance {
|
|
|
9085
9093
|
return this._takeMaximumBoundedDate(this._takeMinimumBoundedDate(date));
|
|
9086
9094
|
}
|
|
9087
9095
|
_takeMinimumBoundedDate(date = this.date) {
|
|
9088
|
-
var _this$
|
|
9089
|
-
if (((_this$
|
|
9096
|
+
var _this$_config$behavio;
|
|
9097
|
+
if (((_this$_config$behavio = this._config.behavior) == null ? void 0 : _this$_config$behavio.capToMinLimit) !== false) {
|
|
9090
9098
|
const min = dateFromLogicalDate(this._limit.min);
|
|
9091
9099
|
if (min && isBefore$1(date, min)) {
|
|
9092
9100
|
date = min;
|
|
@@ -9095,8 +9103,8 @@ class DateTimeMinuteInstance {
|
|
|
9095
9103
|
return date;
|
|
9096
9104
|
}
|
|
9097
9105
|
_takeMaximumBoundedDate(date = this.date) {
|
|
9098
|
-
var _this$
|
|
9099
|
-
if (((_this$
|
|
9106
|
+
var _this$_config$behavio2;
|
|
9107
|
+
if (((_this$_config$behavio2 = this._config.behavior) == null ? void 0 : _this$_config$behavio2.capToMaxLimit) !== false) {
|
|
9100
9108
|
const max = dateFromLogicalDate(this._limit.max);
|
|
9101
9109
|
if (max && isAfter$1(date, max)) {
|
|
9102
9110
|
date = max;
|
|
@@ -10071,8 +10079,12 @@ class BaseRRuleIter {
|
|
|
10071
10079
|
class LastIterResult extends BaseRRuleIter {
|
|
10072
10080
|
constructor(maxIterationsAllowed = DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED) {
|
|
10073
10081
|
super();
|
|
10074
|
-
this.
|
|
10082
|
+
this._maxIterationsAllowed = void 0;
|
|
10075
10083
|
this.maxDate = maxFutureDate();
|
|
10084
|
+
this._maxIterationsAllowed = maxIterationsAllowed;
|
|
10085
|
+
}
|
|
10086
|
+
get maxIterationsAllowed() {
|
|
10087
|
+
return this._maxIterationsAllowed;
|
|
10076
10088
|
}
|
|
10077
10089
|
accept(date) {
|
|
10078
10090
|
++this.total;
|
|
@@ -10081,7 +10093,7 @@ class LastIterResult extends BaseRRuleIter {
|
|
|
10081
10093
|
return false;
|
|
10082
10094
|
} else {
|
|
10083
10095
|
this.add(date);
|
|
10084
|
-
const maxIterationReached = this.total >= this.
|
|
10096
|
+
const maxIterationReached = this.total >= this._maxIterationsAllowed;
|
|
10085
10097
|
return !maxIterationReached;
|
|
10086
10098
|
}
|
|
10087
10099
|
}
|
|
@@ -10090,7 +10102,7 @@ class LastIterResult extends BaseRRuleIter {
|
|
|
10090
10102
|
return true;
|
|
10091
10103
|
}
|
|
10092
10104
|
clone() {
|
|
10093
|
-
return new LastIterResult(this.
|
|
10105
|
+
return new LastIterResult(this._maxIterationsAllowed);
|
|
10094
10106
|
}
|
|
10095
10107
|
}
|
|
10096
10108
|
class NextIterResult extends BaseRRuleIter {
|
package/package.json
CHANGED
|
@@ -48,8 +48,9 @@ export interface LimitDateTimeConfig {
|
|
|
48
48
|
* Used for deriving a limit for the current instant in time.
|
|
49
49
|
*/
|
|
50
50
|
export declare class LimitDateTimeInstance {
|
|
51
|
-
readonly
|
|
51
|
+
private readonly _config;
|
|
52
52
|
constructor(config?: LimitDateTimeConfig);
|
|
53
|
+
get config(): LimitDateTimeConfig;
|
|
53
54
|
get instant(): LogicalDate;
|
|
54
55
|
get minimumMinutesIntoFuture(): Maybe<Minutes>;
|
|
55
56
|
get min(): Maybe<LogicalDate>;
|
|
@@ -67,12 +67,13 @@ export interface RoundDateTimeMinute extends StepRoundDateTimeDown {
|
|
|
67
67
|
* Can step the date forward/backwards, and validate.
|
|
68
68
|
*/
|
|
69
69
|
export declare class DateTimeMinuteInstance {
|
|
70
|
-
|
|
70
|
+
private _config;
|
|
71
71
|
private _date;
|
|
72
72
|
private _step;
|
|
73
73
|
private _limit;
|
|
74
74
|
private _dateFilter;
|
|
75
75
|
constructor(config?: DateTimeMinuteConfig, dateOverride?: Date | null);
|
|
76
|
+
get config(): DateTimeMinuteConfig;
|
|
76
77
|
get date(): Date;
|
|
77
78
|
set date(date: Date);
|
|
78
79
|
get step(): Minutes;
|
|
@@ -50,9 +50,10 @@ declare abstract class BaseRRuleIter {
|
|
|
50
50
|
* Used by DateRRule to find the last result.
|
|
51
51
|
*/
|
|
52
52
|
export declare class LastIterResult extends BaseRRuleIter {
|
|
53
|
-
readonly
|
|
53
|
+
private readonly _maxIterationsAllowed;
|
|
54
54
|
readonly maxDate: Date;
|
|
55
55
|
constructor(maxIterationsAllowed?: number);
|
|
56
|
+
get maxIterationsAllowed(): number;
|
|
56
57
|
accept(date: Date): boolean;
|
|
57
58
|
add(date: Date): boolean;
|
|
58
59
|
clone(): LastIterResult;
|