{"_id":"format-date-locale","_rev":"32-f36f7c535e5bc67f5222dd1d35b9ab8f","name":"format-date-locale","dist-tags":{"latest":"1.5.1"},"versions":{"1.5.0":{"name":"format-date-locale","version":"1.5.0","keywords":["react","next.js","date","formatter","i18n","locale","typescript"],"author":{"name":"Khusnitdin"},"license":"MIT","_id":"format-date-locale@1.5.0","maintainers":[{"name":"khusnitdin","email":"husain.lorent@gmail.com"}],"homepage":"https://github.com/husainlorent/format-date-locale#readme","bugs":{"url":"https://github.com/husainlorent/format-date-locale/issues"},"dist":{"shasum":"f8dc6883a448c498dbf10d69259efc3ef6fd2745","tarball":"https://registry.npmjs.org/format-date-locale/-/format-date-locale-1.5.0.tgz","fileCount":28,"integrity":"sha512-qupTSWzx5etA8TSthA7gRI3J6QQXkuzooxUlkXebr0t6vwo5LmoLplpUrsvRTlfajEQ7YQID6Bzoty5xL1UKoA==","signatures":[{"sig":"MEYCIQCEWnN0B+82Q/68YUS0SbnHCQiytkg4VD1BWfvLE3vidQIhAI+hzSFyPw6+u8PPePBa7QFEgju2tX69K9a1ckyGFNjh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13236},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8909524ae01f1fb9b4486ed6c0d4340b451afc07","scripts":{"test":"jest","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"khusnitdin","email":"husain.lorent@gmail.com"},"repository":{"url":"git+https://github.com/husainlorent/format-date-locale.git","type":"git"},"_npmVersion":"11.3.0","description":"A simple, type-safe, multi-language date formatter for JavaScript and TypeScript.","directories":{},"_nodeVersion":"24.1.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^30.1.3","ts-jest":"^29.4.1","typescript":"^5.2.2","@types/jest":"^30.0.0"},"_npmOperationalInternal":{"tmp":"tmp/format-date-locale_1.5.0_1757998754375_0.8390874330177984","host":"s3://npm-registry-packages-npm-production"}},"1.5.1":{"name":"format-date-locale","version":"1.5.1","description":"A simple, type-safe, multi-language date formatter for JavaScript and TypeScript.","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build","test":"jest"},"keywords":["react","next.js","date","formatter","i18n","locale","typescript"],"author":{"name":"Khusnitdin"},"license":"MIT","devDependencies":{"@types/jest":"^30.0.0","jest":"^30.1.3","ts-jest":"^29.4.1","typescript":"^5.2.2"},"repository":{"type":"git","url":"git+https://github.com/husainlorent/format-date-locale.git"},"_id":"format-date-locale@1.5.1","gitHead":"a673fbb53bc31d30cc89c3c4b550890cf616a5a2","bugs":{"url":"https://github.com/husainlorent/format-date-locale/issues"},"homepage":"https://github.com/husainlorent/format-date-locale#readme","_nodeVersion":"24.1.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-DhatgxSWjVOn+t+Xd94pKGKZAvnEjzH9PrhE83kqTHXDyr+xcPrHXSI/qkLzGoAbP6qI0FNI+dyjtWnSUod/Aw==","shasum":"5140484ea0061a0fb9f0f2113dc31d3fa8cae27c","tarball":"https://registry.npmjs.org/format-date-locale/-/format-date-locale-1.5.1.tgz","fileCount":28,"unpackedSize":13734,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDSwYiGb0yo5eAhuXjsolccsDQA6olm+z0JXAtY5QGZ3wIgQWSeA5fo5U4poCR8xRkaIwwQwiku4A23H4V2bfjrqrU="}]},"_npmUser":{"name":"khusnitdin","email":"husain.lorent@gmail.com"},"directories":{},"maintainers":[{"name":"khusnitdin","email":"husain.lorent@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/format-date-locale_1.5.1_1758112691183_0.16131804201134203"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-15T12:48:07.408Z","modified":"2025-09-17T12:38:11.562Z","1.0.0":"2025-09-15T12:48:07.715Z","1.0.1":"2025-09-15T12:55:01.934Z","1.0.2":"2025-09-15T13:04:23.537Z","1.0.3":"2025-09-15T13:11:01.497Z","1.0.4":"2025-09-16T04:27:05.343Z","1.0.5":"2025-09-16T04:32:56.030Z","1.0.6":"2025-09-16T04:34:29.970Z","1.0.7":"2025-09-16T04:36:17.996Z","1.0.8":"2025-09-16T04:38:20.201Z","1.0.9":"2025-09-16T04:40:03.978Z","1.1.0":"2025-09-16T04:44:13.200Z","1.2.0":"2025-09-16T04:52:25.666Z","1.3.0":"2025-09-16T04:53:24.379Z","1.5.0":"2025-09-16T04:59:14.579Z","1.6.0":"2025-09-17T11:00:07.740Z","1.6.1":"2025-09-17T11:04:04.490Z","1.5.1":"2025-09-17T12:38:11.381Z"},"bugs":{"url":"https://github.com/husainlorent/format-date-locale/issues"},"author":{"name":"Khusnitdin"},"license":"MIT","homepage":"https://github.com/husainlorent/format-date-locale#readme","keywords":["react","next.js","date","formatter","i18n","locale","typescript"],"repository":{"type":"git","url":"git+https://github.com/husainlorent/format-date-locale.git"},"description":"A simple, type-safe, multi-language date formatter for JavaScript and TypeScript.","maintainers":[{"name":"khusnitdin","email":"husain.lorent@gmail.com"}],"readme":"format-date-locale\n\nA simple, type-safe, multi-language date formatter for JavaScript and TypeScript.\nFormat dates in multiple languages with an easy-to-use API. By default, it supports English, Uzbek, Russian, Turkish, French, and Spanish.\n\nFeatures\nMulti-language support: en, uz, ru, tr, fr, es\nType-safe: compile-time validation for locales and options\nOptional day-of-week formatting (withDay)\nEasy to extend with new locales\n\nInstallation\n\n# npm\n\nnpm install format-date-locale\n\n# yarn\n\nyarn add format-date-locale\n\nUsage\n\n## Usage (React)\n\n```tsx\n//Basic usage\n\nimport { formatDate } from \"format-date-locale\";\n\nconst date = new Date();\n\nexport default function Example() {\n  return (\n    <div>\n      <h2>\n        Today’s date: {formatDate(date, \"en\")}\n      </h2>\n      <p>\n        Today’s date (Uzbek or other): {formatDate(date, \"uz\")}\n      </p>\n    </div>\n  );\n}\n\n\n// With API + i18n\n\niimport { formatDate } from \"format-date-locale\";\n\nexport default function Example() {\n  const date = new Date();\n\n  // Example API response\n  const item = { createdAt: \"2025-09-17T10:30:00Z\" };\n\n  // lang can come from i18n or browser settings\n  const lang = \"en\"; // or i18n.language, navigator.language, etc.\n\n  return (\n    <div>\n      {/* Local date */}\n      <h2>\n        Today’s date: {formatDate(date, lang)}\n      </h2>\n\n      {/* Date from API */}\n      <p>\n        Created at: {formatDate(item.createdAt, lang)}\n      </p>\n    </div>\n  );\n}\n\n```\n\nNotes:\ntime can be a Date object or ISO string from API\nlang is a type-safe locale code, TypeScript will throw an error for invalid codes\nUse in any React component to display localized, formatted dates\n\n// 🔹 Create a Date object\nconst today = new Date(2025, 8, 15); // September 15, 2025 (or api)\n\n// 🔹 Default formatting (day not included)\nconsole.log(formatDate(today, \"en\")); // 15 September 2025\nconsole.log(formatDate(today, \"uz\")); // 15 Sentabr 2025\nconsole.log(formatDate(today, \"ru\")); // 15 Сентябрь 2025\nconsole.log(formatDate(today, \"tr\")); // 15 Eylül 2025\nconsole.log(formatDate(today, \"fr\")); // 15 septembre 2025\nconsole.log(formatDate(today, \"es\")); // 15 septiembre 2025\n\n// 🔹 Include day of the week\nconsole.log(formatDate(today, \"uz\", { withDay: true }));\n// Dush, 15 Sentabr 2025\n\n// 🔹 Example: all supported locales with day\nconst locales: Array<\"en\"|\"uz\"|\"ru\"|\"tr\"|\"fr\"|\"es\"> = [\"en\",\"uz\",\"ru\",\"tr\",\"fr\",\"es\"];\nlocales.forEach(loc => {\nconsole.log(`${loc}:`, formatDate(today, loc, { withDay: true }));\n});\n\nSupported Locales\n\n| Locale  | Code |\n| ------- | ---- |\n| English | en   |\n| Uzbek   | uz   |\n| Russian | ru   |\n| Turkish | tr   |\n| French  | fr   |\n| Spanish | es   |\n\nType-safe: only these codes are valid. TypeScript will throw an error for invalid locales.\n\nTypeScript Support\nFully type-safe:\n\nformatDate(new Date(), \"fr\"); // ✅ Only if fr added\nformatDate(new Date(), \"jp\"); // ❌ Error: \"jp\" is not assignable to type Locale\n\nTips\nUse withDay: true to include the day of the week\nExtend with more locales using the steps above\nWorks in both JavaScript and TypeScript projects\nLicense:\nMIT License © Khusnitdin\n","readmeFilename":"README.md"}