How to use terra-date-picker - 9 common examples

To help you get started, we’ve selected a few terra-date-picker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cerner / terra-core / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
constructor(props) {
    super(props);

    this.state = {
      dateTime: DateTimeUtils.createSafeDate(props.value),
      isAmbiguousTime: false,
      isTimeClarificationOpen: false,
      dateFormat: DateUtil.getFormatByLocale(props.intl.locale),
      prevPropsValue: props.value,
    };

    // The dateValue and timeValue variables represent the actual value in the date input and time input respectively.
    // They are used to keep track of the currently entered value to determine whether or not the entry is valid.
    // Unlike dateValue and timeValue, this.state.dateTime is the internal moment object representing both the date and time as one entity
    // It is used for date/time manipulation and used to calculate the missing/ambiguous hour.
    // The dateValue and timeValue are tracked outside of the react state to limit the number of renderings that occur.
    this.dateValue = DateTimeUtils.formatMomentDateTime(this.state.dateTime, this.state.dateFormat);
    this.timeValue = DateTimeUtils.hasTime(this.props.value) ? DateTimeUtils.formatISODateTime(this.props.value, 'HH:mm') : '';
    this.isDefaultDateTimeAcceptable = true;

    this.handleDateChange = this.handleDateChange.bind(this);
    this.handleDateChangeRaw = this.handleDateChangeRaw.bind(this);
    this.handleTimeChange = this.handleTimeChange.bind(this);
    this.handleOnSelect = this.handleOnSelect.bind(this);
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
constructor(props) {
    super(props);

    this.state = {
      dateTime: DateTimeUtils.createSafeDate(props.value),
      isAmbiguousTime: false,
      isTimeClarificationOpen: false,
      dateFormat: DateUtil.getFormatByLocale(props.intl.locale),
      prevPropsValue: props.value,
    };

    // The dateValue and timeValue variables represent the actual value in the date input and time input respectively.
    // They are used to keep track of the currently entered value to determine whether or not the entry is valid.
    // Unlike dateValue and timeValue, this.state.dateTime is the internal moment object representing both the date and time as one entity
    // It is used for date/time manipulation and used to calculate the missing/ambiguous hour.
    // The dateValue and timeValue are tracked outside of the react state to limit the number of renderings that occur.
    this.dateValue = DateTimeUtils.formatMomentDateTime(this.state.dateTime, this.state.dateFormat);
    this.timeValue = DateTimeUtils.hasTime(this.props.value) ? DateTimeUtils.formatISODateTime(this.props.value, 'HH:mm') : '';
    this.isDefaultDateTimeAcceptable = true;
    this.wasOffsetButtonClicked = false;

    this.handleDateChange = this.handleDateChange.bind(this);
    this.handleDateChangeRaw = this.handleDateChangeRaw.bind(this);
    this.handleTimeChange = this.handleTimeChange.bind(this);
github cerner / terra-core / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
validateDefaultDate() {
    let isAcceptable = true;

    if (DateUtil.isDateOutOfRange(this.state.dateTime, DateUtil.createSafeDate(this.props.minDateTime), DateUtil.createSafeDate(this.props.maxDateTime))) {
      isAcceptable = false;
    }

    if (DateUtil.isDateExcluded(this.state.dateTime, this.props.excludeDates)) {
      isAcceptable = false;
    }

    return isAcceptable;
  }
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
isDateTimeWithinRange(newDateTime) {
    let isAcceptable = true;

    if (DateUtil.isDateOutOfRange(newDateTime, DateUtil.createSafeDate(this.props.minDateTime), DateUtil.createSafeDate(this.props.maxDateTime))) {
      isAcceptable = false;
    }

    if (DateUtil.isDateExcluded(newDateTime, this.props.excludeDates)) {
      isAcceptable = false;
    }

    return isAcceptable;
  }
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimeUtils.js View on Github external
static convertDateTimeStringToMomentObject(date, time, dateformat, hasSeconds) {
    return DateTimeUtils.updateTime(DateUtil.createSafeDate(DateUtil.convertToISO8601(date, dateformat)), time, hasSeconds);
  }
}
github cerner / terra-core / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
validateDefaultDate() {
    let isAcceptable = true;

    if (DateUtil.isDateOutOfRange(this.state.dateTime, DateUtil.createSafeDate(this.props.minDateTime), DateUtil.createSafeDate(this.props.maxDateTime))) {
      isAcceptable = false;
    }

    if (DateUtil.isDateExcluded(this.state.dateTime, this.props.excludeDates)) {
      isAcceptable = false;
    }

    return isAcceptable;
  }
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimePicker.jsx View on Github external
isDateTimeWithinRange(newDateTime) {
    let isAcceptable = true;

    if (DateUtil.isDateOutOfRange(newDateTime, DateUtil.createSafeDate(this.props.minDateTime), DateUtil.createSafeDate(this.props.maxDateTime))) {
      isAcceptable = false;
    }

    if (DateUtil.isDateExcluded(newDateTime, this.props.excludeDates)) {
      isAcceptable = false;
    }

    return isAcceptable;
  }
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimeUtils.js View on Github external
static getTime(time, hasSeconds) {
    const timeFormat = hasSeconds ? 'HH:mm:ss' : 'HH:mm';
    return DateUtil.formatISODate(time, timeFormat);
  }
github cerner / terra-framework / packages / terra-date-time-picker / src / DateTimeUtils.js View on Github external
static isValidDateTime(date, time, format, hasSeconds) {
    return DateUtil.isValidDate(date, format) && DateTimeUtils.isValidTime(time, hasSeconds);
  }

terra-date-picker

The terra-date-picker component provides users a way to enter or select a date from the date picker.

Apache-2.0
Latest version published 6 months ago

Package Health Score

54 / 100
Full package analysis