date-fns#endOfDay TypeScript Examples

The following examples show how to use date-fns#endOfDay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeFrameData.ts    From cashcash-desktop with MIT License 6 votes vote down vote up
state: ITimeFrameDataState = {
    parameters: {
        accountIdList: [],
        fromAccountIdList: [],
        toAccountIdList: [],
        currencyIdList: [],
        transactionTypeList: [],
        accountTypeList: [],
        tagIdList: [],
        createdDateFrom: undefined,
        createdDateTo: undefined,
        updatedDateFrom: undefined,
        updatedDateTo: undefined,
        transactionDateFrom: startOfDay(addMonths(DateUtils.newDate(), -6)),
        transactionDateTo: endOfDay(DateUtils.newDate()),
        searchString: undefined,
        detailSearchString: undefined,
        amountLessThan: undefined,
        amountGreaterThan: undefined,
    },

    splitList: [],
    splitSumList: [],
    activeAccountIdSet: new Set(),
    splitListValid: false,
    splitSumListValid: false,
}
Example #2
Source File: ListProviderMonthAvailabilityService.ts    From GoBarber with MIT License 6 votes vote down vote up
public async execute({
    provider_id,
    month,
    year,
  }: IRequest): Promise<IResponse> {
    const appointments = await this.appointmentsRepository.findAllInMonthFromProvider(
      {
        provider_id,
        month,
        year,
      },
    );

    const numberOfDaysInMonth = getDaysInMonth(new Date(year, month - 1));

    const eachDayArray = Array.from(
      { length: numberOfDaysInMonth },
      (_, index) => index + 1,
    );

    const availability = eachDayArray.map(day => {
      const compareDate = endOfDay(new Date(year, month - 1, day));

      const appointmentsInDay = appointments.filter(appointment => {
        return getDate(appointment.date) === day;
      });

      return {
        day,
        available:
          isAfter(compareDate, new Date()) && appointmentsInDay.length < 10,
      };
    });

    return availability;
  }
Example #3
Source File: dateUtils.ts    From ant-extensions with MIT License 5 votes vote down vote up
parseDate = (dt?: string, rounded?: "start" | "end"): ParsedDate => {
  if (dt && isDate(dt)) {
    return parseISO(dt);
  } else if (dt && isDateLike(dt)) {
    const parts = getDateParts(dt);

    if (parts) {
      const { part, op, diff } = parts;
      const diffNum = parseInt(`${op}${diff}`, 10);
      let date = startOfMinute(new Date());

      switch (part) {
        case DateParts.NOW:
          return date;
        case DateParts.DECADE:
          if (rounded) {
            date = (rounded === "start" ? startOfDecade : endOfDecade)(date);
          }
          return addYears(date, diffNum * 10);
        case DateParts.YEAR:
          if (rounded) {
            date = (rounded === "start" ? startOfYear : endOfYear)(date);
          }
          return addYears(date, diffNum);
        case DateParts.QUARTER:
          if (rounded) {
            date = (rounded === "start" ? startOfQuarter : endOfQuarter)(date);
          }
          return addQuarters(date, diffNum);
        case DateParts.MONTH:
          if (rounded) {
            date = (rounded === "start" ? startOfMonth : endOfMonth)(date);
          }
          return addMonths(date, diffNum);
        case DateParts.WEEK:
          if (rounded) {
            date = (rounded === "start" ? startOfWeek : endOfWeek)(date);
          }
          return addWeeks(date, diffNum);
        case DateParts.DAY:
          if (rounded) {
            date = (rounded === "start" ? startOfDay : endOfDay)(date);
          }
          return addDays(date, diffNum);
        case DateParts.HOUR:
          if (rounded) {
            date = (rounded === "start" ? startOfHour : endOfHour)(date);
          }
          return addHours(date, diffNum);
        case DateParts.MINUTE:
          if (rounded) {
            date = (rounded === "start" ? startOfMinute : endOfMinute)(date);
          }
          return addMinutes(date, diffNum);
      }
    }
  }
  return undefined;
}
Example #4
Source File: AbsoluteRangePicker.tsx    From gio-design with Apache License 2.0 5 votes vote down vote up
function AbsoluteRangePicker({ disabledDate, timeRange, onSelect, onRangeSelect, onCancel }: RangePickerProps) {
  const [dates, setDates] = React.useState<[Date | undefined, Date | undefined]>(parseStartAndEndDate(timeRange));
  const prefixCls = usePrefixCls('range-panel__header');

  const locale = useLocale('StaticPastTimePicker');

  const { startDayText, endDayText, FromText, ToText } = {
    ...defaultLocale,
    ...locale,
  };

  const renderHeader = () => {
    const placeholder = [startDayText, endDayText];
    const dateString = formatDates(dates);
    const dateTexts = dateString?.split('-')?.map((d) => (d === ' ' ? undefined : d)) || [];
    const text = [dateTexts[0] ?? placeholder[0], dateTexts[1] ?? placeholder[1]];
    return <span className={`${prefixCls}__text`}>{`${FromText} ${text[0]} ${ToText} ${text[1]}`}</span>;
  };
  const handleDisabledDate = (current: Date) => disabledDate?.(current) || isAfter(current, startOfToday());
  const handleOnOK = () => {
    onSelect(`abs:${getTime(startOfDay(dates[0] as Date))},${getTime(endOfDay(dates[1] as Date))}`);
  };
  const handleOnSelect = (date: [Date, Date], index: number) => {
    setDates(date);
    onRangeSelect?.(date, index);
  }
  const endDay = dates[1] !== undefined && isValid(dates[1]) ? dates[1] : new Date();
  return (
    <InnerRangePanel
      disableOK={!isValid(dates[0]) || !isValid(dates[1])}
      header={renderHeader()}
      body={
        <StaticDateRangePicker
          defaultViewDates={[subMonths(startOfDay(endDay), 1), startOfDay(endDay)]}
          disabledDate={handleDisabledDate}
          onSelect={handleOnSelect}
          value={dates as [Date, Date]}
        />
      }
      onCancel={onCancel}
      onOK={handleOnOK}
    />
  );
}
Example #5
Source File: CalendarModal.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
CalendarModal: FC = () => {
  const isVisible = useAppSelector(({ modal }) => modal.calendar)
  const dispatch = useAppDispatch()
  const { selectedDate, selectDate } = useCalendar()

  const onDayPress: DateCallbackHandler = async ({ timestamp }) => {
    selectDate(new Date(timestamp))
    const startDate = startOfDay(subDays(timestamp, 1)).toISOString()
    const endDate = endOfDay(timestamp).toISOString()
    // dispatch(fetchSle(startDate, endDate)) FIXME
  }

  const toggleModal = () => {
    dispatch(toggleCalendarModal(true))
  }

  const { markedDates } = useMemo(
    () => ({
      markedDates: {
        [format(new Date(selectedDate), 'yyyy-MM-dd')]: {
          selected: true
        }
      }
    }),
    [selectedDate]
  )

  const getMonthData: DateCallbackHandler = ({ month, year }) => {
    dispatch()
    // fetchSleepData(
    //   new Date(year, month - 1, 1).toISOString(),
    //   new Date(year, month - 1, 0).toISOString()
    // ) FIXME
  }

  return (
    <StyledModal
      backdropTransitionOutTiming={0}
      hideModalContentWhileAnimating
      isVisible={isVisible}
      useNativeDriver={false}
      onBackdropPress={toggleModal}>
      <Container>
        <ThemedCalendar
          onMonthChange={getMonthData}
          hideExtraDays
          minDate={minDate}
          markedDates={markedDates}
          showWeekNumbers
          maxDate={new Date()}
          enableSwipeMonths
          onDayPress={onDayPress}
        />
      </Container>
    </StyledModal>
  )
}
Example #6
Source File: sleep.ts    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
getStartEndWeek = (): StartEnd => {
  return {
    startDate: startOfDay(subDays(new Date(), 7)).toISOString(),
    endDate: endOfDay(new Date()).toISOString()
  }
}
Example #7
Source File: sleep.ts    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
getStartEndDay = (): StartEnd => {
  return {
    startDate: startOfDay(new Date()).toISOString(),
    endDate: endOfDay(new Date()).toISOString()
  }
}
Example #8
Source File: tools.ts    From ng-ant-admin with MIT License 5 votes vote down vote up
fnEndOfDay = function EndOfDay(time: number) {
  return endOfDay(time).getTime();
}
Example #9
Source File: Metrics.tsx    From mStable-apps with GNU Lesser General Public License v3.0 5 votes vote down vote up
END_OF_DAY = endOfDay(new Date())
Example #10
Source File: useAvailableSaveApy.ts    From mStable-apps with GNU Lesser General Public License v3.0 5 votes vote down vote up
timestampsForMonth = eachDayOfInterval({
  start: subDays(now, 29),
  end: subDays(now, 1),
})
  .map(endOfDay)
  .concat(now)
Example #11
Source File: model.ts    From office-booker with MIT License 5 votes vote down vote up
getBookingAdminLastCancelTime = (date: string) =>
  endOfDay(parseISO(date)).toISOString()
Example #12
Source File: date.ts    From ngx-gantt with MIT License 5 votes vote down vote up
endOfDay(): GanttDate {
        return new GanttDate(endOfDay(this.value));
    }