mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 05:55:09 +02:00
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com> Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
23 lines
581 B
TypeScript
23 lines
581 B
TypeScript
function isToday (time: number): boolean {
|
|
const current = new Date()
|
|
const target = new Date(time)
|
|
return (
|
|
current.getDate() === target.getDate() &&
|
|
current.getMonth() === target.getMonth() &&
|
|
current.getFullYear() === target.getFullYear()
|
|
)
|
|
}
|
|
|
|
export function getDisplayTime (time: number): string {
|
|
let options: Intl.DateTimeFormatOptions = { hour: 'numeric', minute: 'numeric' }
|
|
if (!isToday(time)) {
|
|
options = {
|
|
month: 'numeric',
|
|
day: 'numeric',
|
|
...options
|
|
}
|
|
}
|
|
|
|
return new Date(time).toLocaleString('default', options)
|
|
}
|