date-fns#isWeekend TypeScript Examples

The following examples show how to use date-fns#isWeekend. 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: sleep-data-helper.ts    From nyxo-app with GNU General Public License v3.0 6 votes vote down vote up
export function calculateSocialJetlag(
  lastSevenDays: Day[]
): {
  weekDayAverage: string
  weekendDayAverage: string
} {
  const weekdays = lastSevenDays.filter(
    (day: Day) => !isWeekend(new Date(day.date))
  )
  const weekendDays = lastSevenDays.filter((day: Day) =>
    isWeekend(new Date(day.date))
  )

  const weekDayAverage = setMinutes(
    startOfDay(new Date()),
    getAverageOfTimes(weekdays)
  ).toISOString()
  const weekendDayAverage = setMinutes(
    startOfDay(new Date()),
    getAverageOfTimes(weekendDays)
  ).toISOString()

  const insights = {
    weekDayAverage,
    weekendDayAverage
  }

  return insights
}
Example #2
Source File: XTicks.tsx    From nyxo-website with MIT License 6 votes vote down vote up
XTicks: FC<Props> = ({ scaleX, chartHeight, barWidth, ticks }) => {
  const tickElements = ticks.map((tick) => {
    const x = scaleX(tick) + barWidth / 2

    isWeekend(new Date(tick))
    return (
      <g key={`tick_${new Date(tick).toISOString()}`}>
        {/* {isWeekend(new Date(tick)) && (
          <rect
            fill="black"
            x={scaleX(tick)}
            y={0}
            height={chartHeight}
            width={barWidth}
          />
        )} */}
        <Day
          // fontFamily={fonts.medium}
          textAnchor="middle"
          x={x}
          y={chartHeight - 5}>
          {format(new Date(tick), "EEE")}
        </Day>
        <LongDate
          // fontFamily=""
          fontWeight="bold"
          textAnchor="middle"
          x={x}
          y={chartHeight - 20}>
          {format(new Date(tick), "dd")}
        </LongDate>
      </g>
    )
  })

  return <g>{tickElements}</g>
}
Example #3
Source File: date.ts    From ngx-gantt with MIT License 5 votes vote down vote up
isWeekend() {
        return isWeekend(this.value);
    }