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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@magik_io/maskit-date

v1.0.0

Published

Date and time mask aliases for Maskit. Provides a `datetime` alias with format-token-based masking, date validation, range checking, and i18n support.

Readme

@maskit/date

Date and time mask aliases for Maskit. Provides a datetime alias with format-token-based masking, date validation, range checking, and i18n support.

Installation

npm install @magik_io/maskit-date @magik_io/maskit-core
# or
pnpm add @magik_io/maskit-date @magik_io/maskit-core

Usage

Register and Use

import { registerDate } from "@magik_io/maskit-date";
import { createMask, format } from "@magik_io/maskit-core";

// Register the "datetime" alias globally
registerDate();

// Create a date mask
const engine = createMask({
  alias: "datetime",
  inputFormat: "MM/dd/yyyy",
});

engine.setValue("12252025");
engine.getValue(); // → "12/25/2025"

With Custom Options

const engine = createMask({
  alias: "datetime",
  inputFormat: "dd/MM/yyyy",
  min: "01/01/2000",   // Minimum date
  max: "31/12/2099",   // Maximum date
  prefillYear: true,    // Auto-fill year digits
});

Custom i18n

import { createDatetimeAlias } from "@magik_io/maskit-date";
import { defineAlias } from "@magik_io/maskit-core";

const spanishDatetime = createDatetimeAlias({
  dayNames: [
    "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", "Dom",
    "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo",
  ],
  monthNames: [
    "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic",
    "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
    "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre",
  ],
  ordinalSuffix: ["°", "°", "°", "°"],
});

defineAlias("datetime-es", spanishDatetime);

Format Tokens

| Token | Description | Example | |-------|-------------|---------| | d | Day (no leading zero) | 1, 15, 31 | | dd | Day (zero-padded) | 01, 15, 31 | | M | Month (no leading zero) | 1, 12 | | MM | Month (zero-padded) | 01, 12 | | MMM | Month short name | Jan, Feb | | MMMM | Month full name | January, February | | yy | 2-digit year | 25 | | yyyy | 4-digit year | 2025 | | h | Hours 12h (no leading zero) | 1, 12 | | hh | Hours 12h (zero-padded) | 01, 12 | | H | Hours 24h (no leading zero) | 0, 23 | | HH | Hours 24h (zero-padded) | 00, 23 | | m | Minutes (no leading zero) | 0, 59 | | mm | Minutes (zero-padded) | 00, 59 | | s | Seconds (no leading zero) | 0, 59 | | ss | Seconds (zero-padded) | 00, 59 | | l | Milliseconds (3-digit) | 000, 999 | | L | Milliseconds (2-digit) | 00, 99 | | t | AM/PM (single char) | a, p | | tt | AM/PM (full) | am, pm | | T | AM/PM upper (single) | A, P | | TT | AM/PM upper (full) | AM, PM | | Z | Timezone | Any string |

Built-in Format Shortcuts

| Name | Format | |------|--------| | isoDate | yyyy-MM-dd | | isoTime | HH:mm:ss | | isoDateTime | yyyy-MM-dd\THH:mm:ss |

Validation Features

  • Day-in-month: Automatically validates days per month (28/29/30/31)
  • Leap year: February 29 is allowed only in leap years
  • Leading zero normalization: Typing 3 for a day auto-prepends 0 when needed
  • Date range: min/max options enforce date boundaries
  • AM/PM casing: Automatic casing for time period tokens

API

registerDate()

Registers the datetime alias into the global @magik_io/maskit-core registry. Call once at app startup.

createDatetimeAlias(i18n?)

Creates a datetime alias definition with optional custom i18n strings. Returns an AliasDefinition that can be passed to defineAlias().

parseDateFormat(format, dateObj?, opts, i18n?)

Parses a date format string into a regex mask pattern (when dateObj is undefined) or formats a DateParts object back to a string (when dateObj is provided).

isValidDate(dateParts, currentResult, opts, maskset?, formatCodes?)

Validates that a DateParts object represents a valid date (day-in-month, leap year checks).

isDateInRange(dateParts, result, opts)

Checks whether a date falls within the min/max range.

pad(val, len?, right?)

Pads a value with leading (or trailing) zeros to the specified length.

Alias Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | inputFormat | string | "isoDateTime" | Date format for input display | | displayFormat | string \| null | null | Alternate format for display | | outputFormat | string \| null | null | Format for unmasked output | | min | string | — | Minimum allowed date | | max | string | — | Maximum allowed date | | prefillYear | boolean | true | Auto-fill year digits | | inputmode | string | "numeric" | Input mode hint |

License

MIT