@editorialapp/datatools
Version:
A collection of dependencies organized into useful tools for working with data in ways that are common in data cleaning and in building news apps.
14 lines (10 loc) • 380 B
JavaScript
import format from 'date-fns/format/index.js'
export function format_time (date, time_format = 'h:mm a') {
return format(new Date(date), time_format)
}
export function format_date (date, date_format = 'MMMM d, yyyy') {
return format(new Date(date), date_format)
}
export function slugify_date (date, date_format = 'yyyy_MM_d') {
return format(new Date(date), date_format)
}