30 lines
867 B
TypeScript
30 lines
867 B
TypeScript
export function capitalizeEachWord(text: string) {
|
|
// const lowercase = text.toLowerCase();
|
|
// return lowercase.charAt(0).toUpperCase() + lowercase.slice(1);
|
|
return text
|
|
.toLowerCase()
|
|
.split(' ')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
.join(' ');
|
|
}
|
|
|
|
export function timestampToDate(timestamp: number, locale: string, options = {}) {
|
|
const date = new Date(timestamp * 1000);
|
|
// locale forma --> `id-ID`
|
|
return date.toLocaleString(locale, {
|
|
// timeZone: options.timeZone,
|
|
weekday: 'long',
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit',
|
|
timeZoneName: 'short',
|
|
...options
|
|
});
|
|
}
|
|
|
|
export function getTimetoMilis() {
|
|
return Math.floor(Date.now() / 1000)
|
|
} |