1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-10 13:56:47 +01:00
immich/web/src/lib/utils/time-to-seconds.ts
Michel Heusschen 4e526dfaae
feat(web): improve and refactor thumbnails (#2087)
* feat(web): improve and refactor thumbnails

* only play live photos on icon hover
2023-03-26 22:53:35 -05:00

13 lines
354 B
TypeScript

import { Duration } from 'luxon';
/**
* Convert time like `01:02:03.456` to seconds.
*/
export function timeToSeconds(time: string) {
const parts = time.split(':');
parts[2] = parts[2].split('.').slice(0, 2).join('.');
const [hours, minutes, seconds] = parts.map(Number);
return Duration.fromObject({ hours, minutes, seconds }).as('seconds');
}