Socket
Socket
Sign inDemoInstall

@blueprintjs/datetime

Package Overview
Dependencies
Maintainers
1
Versions
253
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blueprintjs/datetime - npm Package Compare versions

Comparing version 1.18.0 to 1.19.0

10

dist/common/dateUtils.d.ts

@@ -17,3 +17,12 @@ import * as moment from "moment";

export declare function isMonthInRange(date: Date, dateRange: DateRange): boolean;
export declare const isTimeEqualOrGreaterThan: (time: Date, timeToCompare: Date) => boolean;
export declare const isTimeEqualOrSmallerThan: (time: Date, timeToCompare: Date) => boolean;
export declare function isTimeInRange(date: Date, minDate: Date, maxDate: Date): boolean;
export declare function getTimeInRange(time: Date, minTime: Date, maxTime: Date): Date;
/**
* Returns true if the time part of `date` is later than or equal to the time
* part of `dateToCompare`. The day, month, and year parts will not be compared.
*/
export declare function isTimeSameOrAfter(date: Date, dateToCompare: Date): boolean;
/**
* @returns a Date at the exact time-wise midpoint between startDate and endDate

@@ -23,2 +32,3 @@ */

export declare function getDateTime(date: Date, time: Date): Date;
export declare function getDateOnlyWithTime(date: Date): Date;
export declare function isMomentNull(momentDate: moment.Moment): boolean;

@@ -25,0 +35,0 @@ export declare function isMomentValidAndInRange(momentDate: moment.Moment, minDate: Date, maxDate: Date): boolean;

@@ -109,3 +109,40 @@ /*

exports.isMonthInRange = isMonthInRange;
exports.isTimeEqualOrGreaterThan = function (time, timeToCompare) { return time.getTime() >= timeToCompare.getTime(); };
exports.isTimeEqualOrSmallerThan = function (time, timeToCompare) { return time.getTime() <= timeToCompare.getTime(); };
function isTimeInRange(date, minDate, maxDate) {
var time = getDateOnlyWithTime(date);
var minTime = getDateOnlyWithTime(minDate);
var maxTime = getDateOnlyWithTime(maxDate);
var isTimeGreaterThanMinTime = exports.isTimeEqualOrGreaterThan(time, minTime);
var isTimeSmallerThanMaxTime = exports.isTimeEqualOrSmallerThan(time, maxTime);
if (exports.isTimeEqualOrSmallerThan(maxTime, minTime)) {
return isTimeGreaterThanMinTime || isTimeSmallerThanMaxTime;
}
return isTimeGreaterThanMinTime && isTimeSmallerThanMaxTime;
}
exports.isTimeInRange = isTimeInRange;
function getTimeInRange(time, minTime, maxTime) {
if (areSameTime(minTime, maxTime)) {
return maxTime;
}
else if (isTimeInRange(time, minTime, maxTime)) {
return time;
}
else if (isTimeSameOrAfter(time, maxTime)) {
return maxTime;
}
return minTime;
}
exports.getTimeInRange = getTimeInRange;
/**
* Returns true if the time part of `date` is later than or equal to the time
* part of `dateToCompare`. The day, month, and year parts will not be compared.
*/
function isTimeSameOrAfter(date, dateToCompare) {
var time = getDateOnlyWithTime(date);
var timeToCompare = getDateOnlyWithTime(dateToCompare);
return exports.isTimeEqualOrGreaterThan(time, timeToCompare);
}
exports.isTimeSameOrAfter = isTimeSameOrAfter;
/**
* @returns a Date at the exact time-wise midpoint between startDate and endDate

@@ -132,2 +169,6 @@ */

exports.getDateTime = getDateTime;
function getDateOnlyWithTime(date) {
return new Date(0, 0, 0, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
}
exports.getDateOnlyWithTime = getDateOnlyWithTime;
function isMomentNull(momentDate) {

@@ -134,0 +175,0 @@ return momentDate.parsingFlags().nullInput;

1

dist/dateRangePicker.d.ts

@@ -96,2 +96,3 @@ import { AbstractComponent, IProps } from "@blueprintjs/core";

private setViews(leftView, rightView);
private isShortcutInRange(shortcutDateRange);
}

@@ -98,0 +99,0 @@ export declare const DateRangePickerFactory: React.ComponentFactory<IDateRangePickerProps & {

@@ -266,3 +266,5 @@ /*

var shortcuts = typeof propsShortcuts === "boolean" ? createDefaultShortcuts() : propsShortcuts;
var shortcutElements = shortcuts.map(function (s, i) { return (React.createElement(core_1.MenuItem, { className: core_1.Classes.POPOVER_DISMISS_OVERRIDE, key: i, onClick: _this.getShorcutClickHandler(s.dateRange), text: s.label })); });
var shortcutElements = shortcuts.map(function (s, i) {
return (React.createElement(core_1.MenuItem, { className: core_1.Classes.POPOVER_DISMISS_OVERRIDE, disabled: !_this.isShortcutInRange(s.dateRange), key: i, onClick: _this.getShorcutClickHandler(s.dateRange), text: s.label }));
});
return (React.createElement(core_1.Menu, { className: DateClasses.DATERANGEPICKER_SHORTCUTS }, shortcutElements));

@@ -299,2 +301,5 @@ };

};
DateRangePicker.prototype.isShortcutInRange = function (shortcutDateRange) {
return DateUtils.isDayRangeInRange(shortcutDateRange, [this.props.minDate, this.props.maxDate]);
};
return DateRangePicker;

@@ -301,0 +306,0 @@ }(core_1.AbstractComponent));

2

dist/dateTimePicker.js

@@ -35,3 +35,3 @@ /*

};
var initialValue = (_this.props.value != null) ? _this.props.value : _this.props.defaultValue;
var initialValue = (_this.props.value !== undefined) ? _this.props.value : _this.props.defaultValue;
_this.state = {

@@ -38,0 +38,0 @@ dateValue: initialValue,

@@ -39,2 +39,18 @@ import { IProps } from "@blueprintjs/core";

/**
* The latest time the user can select. The year, month, and day parts of the `Date` object are ignored.
* While the `maxTime` will be later than the `minTime` in the basic case,
* it is also allowed to be earlier than the `minTime`.
* This is useful, for example, to express a time range that extends before and after midnight.
* If the `maxTime` and `minTime` are equal, then the valid time range is constrained to only that one value.
*/
maxTime?: Date;
/**
* The earliest time the user can select. The year, month, and day parts of the `Date` object are ignored.
* While the `minTime` will be earlier than the `maxTime` in the basic case,
* it is also allowed to be later than the `maxTime`.
* This is useful, for example, to express a time range that extends before and after midnight.
* If the `maxTime` and `minTime` are equal, then the valid time range is constrained to only that one value.
*/
minTime?: Date;
/**
* The currently set time.

@@ -52,2 +68,4 @@ * If this prop is provided, the component acts in a controlled manner.

}
export declare function getDefaultMinTime(): Date;
export declare function getDefaultMaxTime(): Date;
export declare class TimePicker extends React.Component<ITimePickerProps, ITimePickerState> {

@@ -54,0 +72,0 @@ static defaultProps: ITimePickerProps;

@@ -22,2 +22,18 @@ /*

})(TimePickerPrecision = exports.TimePickerPrecision || (exports.TimePickerPrecision = {}));
var DEFAULT_MIN_HOUR = 0;
var DEFAULT_MIN_MINUTE = 0;
var DEFAULT_MIN_SECOND = 0;
var DEFAULT_MIN_MILLISECOND = 0;
var DEFAULT_MAX_HOUR = 23;
var DEFAULT_MAX_MINUTE = 59;
var DEFAULT_MAX_SECOND = 59;
var DEFAULT_MAX_MILLISECOND = 999;
function getDefaultMinTime() {
return new Date(0, 0, 0, DEFAULT_MIN_HOUR, DEFAULT_MIN_MINUTE, DEFAULT_MIN_SECOND, DEFAULT_MIN_MILLISECOND);
}
exports.getDefaultMinTime = getDefaultMinTime;
function getDefaultMaxTime() {
return new Date(0, 0, 0, DEFAULT_MAX_HOUR, DEFAULT_MAX_MINUTE, DEFAULT_MAX_SECOND, DEFAULT_MAX_MILLISECOND);
}
exports.getDefaultMaxTime = getDefaultMaxTime;
var TimePicker = (function (_super) {

@@ -89,3 +105,3 @@ tslib_1.__extends(TimePicker, _super);

else {
_this.state = _this.getFullStateFromValue(new Date(0, 0, 0, 0, 0, 0, 0));
_this.state = _this.getFullStateFromValue(props.minTime);
}

@@ -125,2 +141,9 @@ return _this;

TimePicker.prototype.componentWillReceiveProps = function (nextProps) {
var didMinTimeChange = nextProps.minTime !== this.props.minTime;
var didMaxTimeChange = nextProps.maxTime !== this.props.maxTime;
var didBoundsChange = didMinTimeChange || didMaxTimeChange;
if (didBoundsChange) {
var timeInRange = DateUtils.getTimeInRange(this.state.value, nextProps.minTime, nextProps.maxTime);
this.setState(this.getFullStateFromValue(timeInRange));
}
if (nextProps.value != null && !DateUtils.areSameTime(nextProps.value, this.props.value)) {

@@ -150,9 +173,10 @@ this.setState(this.getFullStateFromValue(nextProps.value));

TimePicker.prototype.getFullStateFromValue = function (value) {
var timeInRange = DateUtils.getTimeInRange(value, this.props.minTime, this.props.maxTime);
/* tslint:disable:object-literal-sort-keys */
return {
hourText: formatTime(value.getHours(), TimeUnit.HOUR),
minuteText: formatTime(value.getMinutes(), TimeUnit.MINUTE),
secondText: formatTime(value.getSeconds(), TimeUnit.SECOND),
millisecondText: formatTime(value.getMilliseconds(), TimeUnit.MS),
value: value,
hourText: formatTime(timeInRange.getHours(), TimeUnit.HOUR),
minuteText: formatTime(timeInRange.getMinutes(), TimeUnit.MINUTE),
secondText: formatTime(timeInRange.getSeconds(), TimeUnit.SECOND),
millisecondText: formatTime(timeInRange.getMilliseconds(), TimeUnit.MS),
value: timeInRange,
};

@@ -176,6 +200,12 @@ /* tslint:enable:object-literal-sort-keys */

TimePicker.prototype.updateTime = function (time, unit) {
var newValue = DateUtils.clone(this.state.value);
var _a = this.props, minTime = _a.minTime, maxTime = _a.maxTime;
if (isTimeValid(time, unit)) {
var newValue = DateUtils.clone(this.state.value);
setTimeUnit(time, newValue, unit);
this.updateState({ value: newValue });
if (DateUtils.isTimeInRange(newValue, minTime, maxTime)) {
this.updateState({ value: newValue });
}
else if (!DateUtils.areSameTime(this.state.value, minTime)) {
this.updateState(this.getFullStateFromValue(newValue));
}
}

@@ -219,2 +249,4 @@ else {

disabled: false,
maxTime: getDefaultMaxTime(),
minTime: getDefaultMinTime(),
precision: TimePickerPrecision.MINUTE,

@@ -287,6 +319,6 @@ selectAllOnFocus: false,

var min = (_a = {},
_a[TimeUnit.HOUR] = 0,
_a[TimeUnit.MINUTE] = 0,
_a[TimeUnit.SECOND] = 0,
_a[TimeUnit.MS] = 0,
_a[TimeUnit.HOUR] = DEFAULT_MIN_HOUR,
_a[TimeUnit.MINUTE] = DEFAULT_MIN_MINUTE,
_a[TimeUnit.SECOND] = DEFAULT_MIN_SECOND,
_a[TimeUnit.MS] = DEFAULT_MIN_MILLISECOND,
_a);

@@ -298,6 +330,6 @@ return min[unit];

var max = (_a = {},
_a[TimeUnit.HOUR] = 23,
_a[TimeUnit.MINUTE] = 59,
_a[TimeUnit.SECOND] = 59,
_a[TimeUnit.MS] = 999,
_a[TimeUnit.HOUR] = DEFAULT_MAX_HOUR,
_a[TimeUnit.MINUTE] = DEFAULT_MAX_MINUTE,
_a[TimeUnit.SECOND] = DEFAULT_MAX_SECOND,
_a[TimeUnit.MS] = DEFAULT_MAX_MILLISECOND,
_a);

@@ -304,0 +336,0 @@ return max[unit];

{
"name": "@blueprintjs/datetime",
"version": "1.18.0",
"version": "1.19.0",
"description": "Components for interacting with dates and times",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -113,3 +113,44 @@ /*

export const isTimeEqualOrGreaterThan = (time: Date, timeToCompare: Date) => time.getTime() >= timeToCompare.getTime();
export const isTimeEqualOrSmallerThan = (time: Date, timeToCompare: Date) => time.getTime() <= timeToCompare.getTime();
export function isTimeInRange(date: Date, minDate: Date, maxDate: Date): boolean {
const time = getDateOnlyWithTime(date);
const minTime = getDateOnlyWithTime(minDate);
const maxTime = getDateOnlyWithTime(maxDate);
const isTimeGreaterThanMinTime = isTimeEqualOrGreaterThan(time, minTime);
const isTimeSmallerThanMaxTime = isTimeEqualOrSmallerThan(time, maxTime);
if (isTimeEqualOrSmallerThan(maxTime, minTime)) {
return isTimeGreaterThanMinTime || isTimeSmallerThanMaxTime;
}
return isTimeGreaterThanMinTime && isTimeSmallerThanMaxTime;
}
export function getTimeInRange(time: Date, minTime: Date, maxTime: Date) {
if (areSameTime(minTime, maxTime)) {
return maxTime;
} else if (isTimeInRange(time, minTime, maxTime)) {
return time;
} else if (isTimeSameOrAfter(time, maxTime)) {
return maxTime;
}
return minTime;
}
/**
* Returns true if the time part of `date` is later than or equal to the time
* part of `dateToCompare`. The day, month, and year parts will not be compared.
*/
export function isTimeSameOrAfter(date: Date, dateToCompare: Date): boolean {
const time = getDateOnlyWithTime(date);
const timeToCompare = getDateOnlyWithTime(dateToCompare);
return isTimeEqualOrGreaterThan(time, timeToCompare);
}
/**
* @returns a Date at the exact time-wise midpoint between startDate and endDate

@@ -135,2 +176,6 @@ */

export function getDateOnlyWithTime(date: Date): Date {
return new Date(0, 0, 0, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
}
export function isMomentNull(momentDate: moment.Moment) {

@@ -137,0 +182,0 @@ return momentDate.parsingFlags().nullInput;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc