Package Exports
- sofi-date
- sofi-date/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sofi-date) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sofi-date
A flexible date formatter for Node.js with support for both international (YYYY-MM-DD) and US (MM/DD/YYYY) formats. Easily format dates in different languages and styles.
Installation
npm install sofi-dateUsage
const { formateFull, formateShort } = require('sofi-date');
// Full date formatting
console.log(formateFull("2025-03-17T22:17:15", "es-ES")); // "17 de Marzo de 2025"
console.log(formateFull("2025-03-17T22:17:15", "en-US")); // "March 17, 2025"
// Short date formatting
console.log(formateShort("2025-03-17T22:17:15", "es-ES")); // "17/Mar/2025"
console.log(formateShort("2025-03-17T22:17:15", "en-US")); // "Mar/17/2025"
Supported Locales
Currently, the library fully supports the following locales:
es-ES(Spanish)en-US(English - United States)
Other locales may work but have not been specifically tested or optimized.
API Reference
formateFull(date, locale)
Formats a date into its full text representation based on the specified locale.
Parameters:
date(String|Date): The date to format. Can be a Date object or a string parseable by the Date constructor.locale(String): The locale to use for formatting (e.g., "es-ES", "en-US").
Returns:
- (String): The formatted date string in full text format.
Examples:
formateFull("2025-03-17", "es-ES"); // "17 de Marzo de 2025"
formateFull("2025-03-17", "en-US"); // "March 17, 2025"formateShort(date, locale)
Formats a date into a short representation with abbreviated month name.
Parameters:
date(String|Date): The date to format. Can be a Date object or a string parseable by the Date constructor.locale(String): The locale to use for formatting (e.g., "es-ES", "en-US").
Returns:
- (String): The formatted date string in abbreviated format. Examples:
formateShort("2025-03-17", "es-ES"); // "17/Mar/2025"
formateShort("2025-03-17", "en-US"); // "Mar/17/2025"Support Development ☕
MIT Licensed | Full Documentation