
tictic is a tiny JavaScript utility for formatting dates and times in web applications.
You can easily customize date/time outputs, localize month names, increment/decrement days, format weekdays, specify time formats, and more.
How to use it:
1. Install and import the required modules as follows:
# NPM $ npm i tictic
import { getFormattedDate, getFormattedTime } from 'tictic'2. Format a specific date:
const formattedDate = getFormattedDate({
// Accept the same input as the native new Date()
date: new Date(),
// Custom separator
sep: '-',
// Custom date format
format: 'DD-MM-YYYY',
// Exception Object
exclude: { year: false, month: false, day: false, zero: false },
// Localize month names here
nameOfMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
weekDays: {
// Responsible for displaying the day of the week
set: true,
// Accept the same input as the native method Date.toLocaleString
locale: 'en',
// 'long' | 'short' | 'narrow'
format: 'short',
// 'capitalize' | 'uppercase' | 'lowercase'
case: 'uppercase',
// 'start' | 'end'
position: 'end'
},
// Increases by n days
incDay: 0
});
console.log(formattedDate);
// Oct-26-2023 THU3. Format a specific time.
const formattedTime = getFormattedTime({
time: new Date().getTime(),
sep: ':',
format: 'hh:mm:ss',
meridiem: {
format: '12h',
case: 'uppercase',
position: 'end',
}
});
console.log(formattedTime);
// 13:13:58






