1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-25 05:02:46 +01:00
immich/web/src/lib/utils/time-to-seconds.ts
Jason Rasmussen f55b3add80
chore(web): prettier (#2821)
Co-authored-by: Thomas Way <thomas@6f.io>
2023-06-30 23:50:47 -05:00

13 lines
358 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');
}