npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@akcelepatop/dayspan

v0.1.7

Published

A date & schedule library to use for advanced calendars in TypeScript and JS

Downloads

55

Readme

DaySpan

A date & schedule library to use for advanced calendars in TypeScript and JS.

Features

  • Schedules track how frequent events occur using 20+ properties
  • Events can last minutes, hours, days, or weeks
  • Events can occur all day, or 1 or more times during the day
  • Events can have any day & time included as an event occurrence (they don't need to match the frequency of the schedule)
  • Events can be excluded, cancelled, or have metadata (specific event occurrence, all in a given day, week, month, quarter, or year)
  • Event occurrences can be moved
  • Calendars can represent a span of days, weeks, months, or years
  • Easily list the next/previous days that occur on a schedule
  • Describe a schedule in a human friendly string
  • Export and import schedules and calendars to plain objects for easy saving and loading
  • Provides logic to help display intersecting events on a calendar

TypeScript Example

// A monthly calendar around today (string=event data type, any=schedule metadata type)
let cal = Calendar.months<string, any>();

// Every Monday 9:00 - 9:30
cal.addEvent({
  data: 'Weekly Meeting',
  schedule: {
    dayOfWeek: [Weekday.MONDAY],
    times: [9],
    duration: 30,
    durationUnit: 'minutes'
  }
});

// Dr. Appointment on 01/04/2018
cal.addEvent({
  data: 'Dr. Appointment',
  visible: false,
  schedule: {
    on: Day.build(2018, Month.APRIL, 1)
  }
});

// Mother's Day
cal.addEvent({
  id: 'someUserProvidedId',
  data: "Mother's Day",
  schedule: new Schedule({
    weekspanOfMonth: [1],         // 2nd
    dayOfWeek: [Weekday.SUNDAY],  // Sunday
    month: [Month.MAY]            // of May
  })
});

// The array of days in the month, each day has a list of the days events.
cal.days;

// Go to the next month
cal.next();

// Select this day and update the selection flags in the calendar days
cal.select(Day.build(2018, Month.APRIL, 12));

// Remove the schedule
cal.removeEvent('Weekly Meeting');

// A weekly calendar with custom MyEvent class
Calendar.weeks<MyEvent, any>();

// A daily calendar covering 3 days centered on today
Calendar.days<string, any>(3);

// A daily calendar covering 3 days starting with given date
Calendar.days<string, any>(3, Day.build(2018, Month.JUNE, 15), 0);

JS Example

You just need to append ds to the beginning of the classes:

// A monthly calendar around today
var cal = ds.Calendar.months();

// Every Monday 9:00 - 9:30
cal.addEvent({
  data: 'Weekly Meeting',
  schedule: {
    dayOfWeek: [ds.Weekday.MONDAY],
    times: [9],
    duration: 30,
    durationUnit: 'minutes'
  }
});

// Dr. Appointment on 01/04/2018
cal.addEvent({
  data: 'Dr. Appointment',
  schedule: new ds.Schedule({
    on: ds.Day.build(2018, ds.Month.APRIL, 1)
  })
});