How to use the nodemod/dist/calendar/to-utc-date.js.toUTCDate function in nodemod

To help you get started, we’ve selected a few nodemod 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 motss / app-datepicker / src / helpers / get-multi-calendars.ts View on Github external
const calendarsList = [-1, 0, 1].map((n) => {
    const firstDayOfMonth = toUTCDate(ify, im + n, 1);
    const lastDayOfMonthTime = +toUTCDate(ify, im + n + 1, 0);
    const key = getKey(firstDayOfMonth);

    /**
     * NOTE: Return `null` when one of the followings fulfills:-
     *
     *           minTime            maxTime
     *       |--------|--------o--------|--------|
     *   last day     |   valid dates   |     first day
     *
     *  - last day of the month < `minTime` - entire month should be disabled
     *  - first day of the month > `maxTime` - entire month should be disabled
     */
    if (lastDayOfMonthTime < minTime || +firstDayOfMonth > maxTime) {
      return {
        key,
github motss / app-datepicker / src / helpers / compute-next-focus-date.ts View on Github external
*/
  if (keyCode === KEY_CODES_MAP.PAGE_DOWN || keyCode === KEY_CODES_MAP.PAGE_UP) {
    const totalDaysOfMonth = toUTCDate(fy, m + 1, 0).getUTCDate();
    if (d > totalDaysOfMonth) {
      d = totalDaysOfMonth;
    }
  }

  /** Get next selectable focused date */
  const newFocusedDate = getNextSelectableDate({
    keyCode,
    maxTime,
    minTime,
    disabledDaysSet,
    disabledDatesSet,
    focusedDate: toUTCDate(fy, m, d),
  });

  return newFocusedDate;
}
github motss / app-datepicker / src / app-datepicker.ts View on Github external
const handleUpdateMonth = () => {
      const calendarsContainer = this.calendarsContainer;

      if (null ==  calendarsContainer) return this.updateComplete;

      const dateDate = this._lastSelectedDate || this._selectedDate;
      const minDate = this._min!;
      const maxDate = this._max!;

      const isPreviousMonth = updateType === 'previous';

      const newSelectedDate = toUTCDate(
        dateDate.getUTCFullYear(),
        dateDate.getUTCMonth() + (isPreviousMonth ? -1 : 1),
        1);
      const newSelectedDateFy = newSelectedDate.getUTCFullYear();
      const newSelectedDateM = newSelectedDate.getUTCMonth();

      const minDateFy = minDate.getUTCFullYear();
      const minDateM = minDate.getUTCMonth();

      const maxDateFy = maxDate.getUTCFullYear();
      const maxDateM = maxDate.getUTCMonth();

      /**
       * NOTE: Instead of debouncing/ throttling the animation when switching between
       * calendar months, this prevents subsequent animation that can cause an issue
       * where a blank calendar comes into view to be queued by ensuring the new updated
github motss / app-datepicker / src / helpers / compute-next-focus-date.ts View on Github external
default: {
      d = 1;
      break;
    }
  }

  /**
   * NOTE(motss): When updating month and year, check if the value of day exceeds
   * the total days of the updated date. If true, then focus the last day of the new month.
   * This also applies to the following cases:
   *
   * - `2020-01-31` -> next month -> `2020-02-31` (invalid) -> fallback to `2020-02-29`
   * - `2020-02-29` -> next year -> `2021-02-29` (invalid) -> fallback to `2021-02-28`
   */
  if (keyCode === KEY_CODES_MAP.PAGE_DOWN || keyCode === KEY_CODES_MAP.PAGE_UP) {
    const totalDaysOfMonth = toUTCDate(fy, m + 1, 0).getUTCDate();
    if (d > totalDaysOfMonth) {
      d = totalDaysOfMonth;
    }
  }

  /** Get next selectable focused date */
  const newFocusedDate = getNextSelectableDate({
    keyCode,
    maxTime,
    minTime,
    disabledDaysSet,
    disabledDatesSet,
    focusedDate: toUTCDate(fy, m, d),
  });

  return newFocusedDate;
github motss / app-datepicker / src / helpers / get-multi-calendars.ts View on Github external
const calendarsList = [-1, 0, 1].map((n) => {
    const firstDayOfMonth = toUTCDate(ify, im + n, 1);
    const lastDayOfMonthTime = +toUTCDate(ify, im + n + 1, 0);
    const key = getKey(firstDayOfMonth);

    /**
     * NOTE: Return `null` when one of the followings fulfills:-
     *
     *           minTime            maxTime
     *       |--------|--------o--------|--------|
     *   last day     |   valid dates   |     first day
     *
     *  - last day of the month < `minTime` - entire month should be disabled
     *  - first day of the month > `maxTime` - entire month should be disabled
     */
    if (lastDayOfMonthTime < minTime || +firstDayOfMonth > maxTime) {
      return {
        key,
github motss / app-datepicker / src / helpers / get-selectable-date.ts View on Github external
if (!isDisabledDay) return focusedDate;

  let selectableFocusedDateTime = 0;
  let selectableFocusedDate = isLessThanMinTime === isMoreThanMaxTime ?
    focusedDate : new Date(isLessThanMinTime ? minTime - 864e5 : 864e5 + maxTime);

  const fy = selectableFocusedDate.getUTCFullYear();
  const m = selectableFocusedDate.getUTCMonth();
  let d = selectableFocusedDate.getUTCDate();

  while (isDisabledDay) {
    if (isLessThanMinTime || (!isMoreThanMaxTime && NEXT_DAY_KEY_CODES_SET.has(keyCode))) d += 1;
    if (isMoreThanMaxTime || (!isLessThanMinTime && PREV_DAY_KEY_CODES_SET.has(keyCode))) d -= 1;

    selectableFocusedDate = toUTCDate(fy, m, d);
    selectableFocusedDateTime = +selectableFocusedDate;

    if (!isLessThanMinTime) {
      isLessThanMinTime = selectableFocusedDateTime < minTime;

      if (isLessThanMinTime) {
        selectableFocusedDate = new Date(minTime);
        selectableFocusedDateTime = +selectableFocusedDate;
        d = selectableFocusedDate.getUTCDate();
      }
    }

    if (!isMoreThanMaxTime) {
      isMoreThanMaxTime = selectableFocusedDateTime > maxTime;

      if (isMoreThanMaxTime) {
github motss / app-datepicker / src / app-datepicker.ts View on Github external
${this._yearList.map(n =>
        html`<button class="${classMap({
            'year-list-view__list-item': true,
            'year--selected': focusedDateFy === n,
          })}">
          <div>${yearFormat(toUTCDate(n, 0, 1))}</div>
        </button>`)
      }

nodemod

A collection of node modules for The Really Project

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis