SPB Git

spb/trouve-ka Public

Trouve-KA — moteur de recherche web indépendant, Québec-first. Crawler distribué, index OpenSearch, ranking bilingue, galerie d'images. En prod : www.trouve-ka.com

Python 76.8% TypeScript 15.7% SQL 3.9% Shell 1.4% CSS 1.3% Dockerfile 0.7%
1.0 KB · 39 lines typescript
Raw Blame History
1/**2 * Trouve-KA — formatage fr-CA (nombres, dates, heures)3 * Author: Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 */67const numberFormat = new Intl.NumberFormat("fr-CA");89const dateFormat = new Intl.DateTimeFormat("fr-CA", {10  year: "numeric",11  month: "long",12  day: "numeric",13});1415const timeFormat = new Intl.DateTimeFormat("fr-CA", {16  hour: "2-digit",17  minute: "2-digit",18  second: "2-digit",19});2021/** Formate un nombre en fr-CA (séparateurs de milliers insécables). */22export function formatNumber(value: number): string {23  return numberFormat.format(value);24}2526/** Formate une date ISO en date longue fr-CA (ex. « 13 août 2026 »). */27export function formatDate(iso: string): string {28  const date = new Date(iso);29  if (Number.isNaN(date.getTime())) return "";30  return dateFormat.format(date);31}3233/** Formate une date ISO en heure fr-CA (ex. « 14 h 05 min 12 s »). */34export function formatTime(iso: string): string {35  const date = new Date(iso);36  if (Number.isNaN(date.getTime())) return "";37  return timeFormat.format(date);38}39