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

@spiderbanana/date-smart-formatter

v1.0.0

Published

📅 Un formateur de dates intelligent avec smart label et support multi-langues.

Downloads

6

Readme

📅 date-smart-formatter

Un formateur de dates intelligent avec support multi-locales et smart labels (Aujourd'hui, Hier, etc.).

✨ Fonctionnalités

  • 🌍 Support multi-langues : Français, Anglais, Espagnol, Allemand
  • 🔮 Smart Labels : "Aujourd'hui", "Hier", "Demain", etc.
  • 🌐 Gestion des fuseaux horaires
  • 📝 Templates personnalisables avec tokens flexibles
  • 🔧 Parser intelligent pour différents formats d'entrée
  • 📦 TypeScript avec types complets

🚀 Installation

npm install @votre-nom-npm/date-smart-formatter

📖 Usage

Usage basique

import { formatDate } from '@votre-nom-npm/date-smart-formatter';

// Format par défaut (français)
formatDate(new Date()); // "08/07/2025"
formatDate('2024-01-15'); // "15/01/2024"

// Avec smart labels
formatDate(new Date()); // "Aujourd'hui"
formatDate(new Date(Date.now() - 86400000)); // "Hier"

Options avancées

// Format personnalisé
formatDate(new Date(), {
  format: 'DD MMMM YYYY à HH:mm',
  locale: 'fr-FR',
}); // "08 juillet 2025 à 14:30"

// Locales différentes
formatDate(new Date(), {
  format: 'MMMM DD, YYYY',
  locale: 'en-US',
}); // "July 08, 2025"

// Gestion des fuseaux horaires
formatDate(new Date(), {
  timezone: 'America/New_York',
  format: 'DD/MM/YYYY HH:mm',
}); // Date convertie vers New York

// Désactiver les smart labels
formatDate(new Date(), {
  useSmartLabels: false,
  format: 'DD/MM/YYYY',
}); // "08/07/2025" (même si c'est aujourd'hui)

Templates de formatage

| Token | Description | Exemple | | ------ | ---------------------- | ----------------- | | DD | Jour (2 chiffres) | 01, 15, 31 | | D | Jour | 1, 15, 31 | | MMMM | Nom du mois complet | janvier, February | | MMM | Nom du mois court | jan, Feb | | MM | Mois (2 chiffres) | 01, 12 | | M | Mois | 1, 12 | | YYYY | Année complète | 2024 | | YY | Année (2 chiffres) | 24 | | HH | Heure 24h (2 chiffres) | 00, 14, 23 | | H | Heure 24h | 0, 14, 23 | | hh | Heure 12h (2 chiffres) | 01, 02, 12 | | h | Heure 12h | 1, 2, 12 | | mm | Minutes (2 chiffres) | 00, 30, 59 | | m | Minutes | 0, 30, 59 | | ss | Secondes (2 chiffres) | 00, 30, 59 | | s | Secondes | 0, 30, 59 | | A | AM/PM | AM, PM | | a | am/pm | am, pm |

Smart Labels supportés

| Français | Anglais | Espagnol | Allemand | | ------------------- | ---------- | ---------------- | ------------ | | Aujourd'hui | Today | Hoy | Heute | | Hier | Yesterday | Ayer | Gestern | | Demain | Tomorrow | Mañana | Morgen | | Cette semaine | This week | Esta semana | Diese Woche | | La semaine dernière | Last week | La semana pasada | Letzte Woche | | Ce mois-ci | This month | Este mes | Diesen Monat |

Utilisation avancée

import {
  parseDate,
  getSmartLabel,
  localizeDate,
  formatTemplate,
  handleTimezone,
} from '@votre-nom-npm/date-smart-formatter';

// Parser une date
const parsed = parseDate('15/01/2024');

// Obtenir un smart label
const label = getSmartLabel(new Date(), 'fr-FR');

// Localiser les composants d'une date
const components = localizeDate(new Date(), 'fr-FR');
console.log(components.monthName); // "juillet"

// Formater avec un template
const formatted = formatTemplate('DD MMMM', components, new Date());

// Gérer les fuseaux horaires
const parisTime = handleTimezone(new Date(), 'Europe/Paris');

🔧 API

formatDate(input, options?)

Fonction principale pour formater une date.

Paramètres :

  • input: string | Date | number - Date à formater
  • options: FormatOptions - Options de formatage

Options :

  • locale?: string - Locale (défaut: 'fr-FR')
  • timezone?: string - Fuseau horaire (défaut: 'Europe/Paris')
  • format?: string - Template de formatage (défaut: 'DD/MM/YYYY')
  • useSmartLabels?: boolean - Utiliser les smart labels (défaut: true)

Fonctions utilitaires

  • parseDate(input) - Parse une date depuis différents formats
  • getSmartLabel(date, locale) - Obtient un smart label si applicable
  • localizeDate(date, locale) - Localise les composants d'une date
  • formatTemplate(template, components, date) - Applique un template
  • handleTimezone(date, timezone) - Convertit vers un fuseau horaire

🌍 Locales supportées

  • fr-FR - Français (France)
  • en-US - Anglais (États-Unis)
  • es-ES - Espagnol (Espagne)
  • de-DE - Allemand (Allemagne)

🕐 Fuseaux horaires

Supporte tous les fuseaux horaires IANA, par exemple :

  • Europe/Paris
  • America/New_York
  • Asia/Tokyo
  • UTC

🧪 Tests

npm test

🏗️ Build

npm run build

📝 Licence

MIT"# date-formater"