{"id":41422,"library":"lit-date","title":"lit-date","description":"Lit-date is a lightweight (~1kB gzipped) and fast datetime formatter for modern browsers, using template literals for formatting. Version 1.0.5 is the current stable release. Unlike moment.js or date-fns, it uses tagged template literals (e.g., litdate`${'YYYY'}/${'MM'}/${'DD'}`(date)) and supports internationalization via custom functions. It is significantly faster than Moment.js and Day.js based on benchmarks. The library ships TypeScript types and supports both Node.js and browser environments via ESM or UMD bundles.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/3846masa/lit-date","tags":["javascript","date","datetime","format","formatter","typescript"],"install":[{"cmd":"npm install lit-date","lang":"bash","label":"npm"},{"cmd":"yarn add lit-date","lang":"bash","label":"yarn"},{"cmd":"pnpm add lit-date","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"lit-date is an ESM-only package; CommonJS require() will not work.","wrong":"const litdate = require('lit-date')","symbol":"litdate","correct":"import litdate from 'lit-date'"},{"note":"litdate is the default export, not a named export.","wrong":"const { litdate } = require('lit-date')","symbol":"litdate (default export as function)","correct":"import litdate from 'lit-date'; const format = litdate`${'YYYY'}/${'MM'}/${'DD'}`;"},{"note":"TypeScript types are included; no separate @types package needed.","wrong":null,"symbol":"TypeScript types","correct":"import litdate from 'lit-date'"}],"quickstart":{"code":"import litdate from 'lit-date';\n\nconst format = litdate`${'YYYY'}/${'MM'}/${'DD'} ${'HH'}:${'mm'}:${'ss'}`;\nconst now = new Date();\nconsole.log(format(now)); // e.g., \"2023/04/01 12:30:45\"","lang":"typescript","description":"Demonstrates basic usage of lit-date with a template literal to format a Date object into a custom string pattern."},"warnings":[{"fix":"Ensure all placeholders are string literals: `${'YYYY'}` instead of `${year}`.","message":"Template literal placeholders must be string literals like `${'YYYY'}`, not variables. Using variables like `${year}` will not work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always call the result: litdate`...`(date).","message":"The function returned by the tagged template is curried; you must call it with a Date object to get a string. Forgetting the second invocation returns a function.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a library like date-fns-tz if timezone support is needed.","message":"lit-date does not support timezone formatting; dates are always formatted in local time.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import or dynamic import(). For CommonJS projects, consider using a bundler or switching to a compatible library.","message":"The package is ESM-only; it cannot be used with require() in Node.js without dynamic import or transpilation.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only include the format tokens you need; unused tokens add minimal size.","message":"BundlePhobia shows the package as ~1kB gzipped, but tree-shaking may not remove unused format tokens because the template literal structure is static.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.5':25 '1kb':10 'base':62 'benchmark':64 'browser':18,75 'bundl':81 'current':28 'custom':52 'date':3,6,35,47,83 'date-fn':34 'datetim':14,84 'day.js':61 'dd':46 'e.g':42 'environ':76 'esm':78 'fast':13 'faster':57 'fns':36 'format':23,85 'formatt':15,86 'function':53 'gzip':11 'internation':50 'javascript':82 'librari':66 'lightweight':9 'lit':2,5 'lit-dat':1,4 'litdat':43 'liter':21,41 'mm':45 'modern':17 'moment.js':32,59 'node.js':73 'releas':30 'ship':67 'signific':56 'stabl':29 'support':49,71 'tag':39 'templat':20,40 'type':69 'typescript':68,87 'umd':80 'unlik':31 'use':19,38 'version':24 'via':51,77 'yyyi':44","created_at":"2026-06-04T18:52:20.507495+00:00","updated_at":"2026-06-04T18:52:20.507495+00:00","problems":[{"fix":"Replace variable placeholders with string literals: litdate`${'YYYY'}`.","cause":"Using variables inside template literal instead of string literals, e.g., litdate`${year}` instead of litdate`${'year'}`.","error":"SyntaxError: Unexpected template string"},{"fix":"Change to import litdate from 'lit-date' or use dynamic import().","cause":"Attempting to use require() to import the package, which is ESM-only.","error":"TypeError: litdate is not a function"},{"fix":"Add <script type=\"module\"> and import litdate from the CDN URL.","cause":"Forgetting to import the package or using a CDN script without proper module type.","error":"ReferenceError: litdate is not defined"},{"fix":"Ensure the template literal is immediately invoked: litdate`${'YYYY'}`(new Date()).","cause":"Calling the result of litdate`...` incorrectly, e.g., litdate`${'YYYY'}`(new Date()) where the tagged template returns a function, but forgetting to call it.","error":"TypeError: (intermediate value) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/3846masa/lit-date#readme","github":"ssh://git@github.com/3846masa/lit-date","docs":null,"changelog":null,"pypi":null,"npm":"lit-date","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}