Socket
Book a DemoInstallSign in
Socket

caltils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caltils

Utility functions for building calendar components. This code was based on [ngx-ui/calendar](https://github.com/swimlane/ngx-ui/blob/master/projects/swimlane/ngx-ui/src/lib/components/calendar/utils/get-weeks-for-days/get-weeks-for-days.util.ts).

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Caltils

Utility functions for building calendar components. This code was based on ngx-ui/calendar.

Usage

yarn add caltils

...then import and invoke...

import { getWeeks } from 'caltils';

const weeksWithDays: Day[][] = getWeeks(new Date());

...then you can render something like this...

import React, { FC } from 'react';
import { getWeeks } from 'caltils';

interface CalendarProps {
  date: Date;
}

const Calendar: FC<CalendarProps> = ({ date }) => {
  const weeksWithDays: Day[][] = getWeeks(date);
  return (
    <>
      {weeks.map((week, i) => (
        <div>
          {week.map((day, ii) => (
            <button>{day.dayOfMonth}</button>
          )}
        </div>
      )}
    </>
  );
};

API

export interface Day {
  date: Date;
  dayOfMonth: number;
  isWeekendDay: boolean;
  isPreviousMonth: boolean;
  isNextMonth: boolean;
  isToday: boolean;
  formattedDate: string;
}

export interface DayOptions {
  format: string;
}

export function getWeeks(
  date: Date,
  options: DayOptions = { format: 'MM/DD/YYYY' }
): Day[][] {}

FAQs

Package last updated on 05 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.