mirror of
https://github.com/immich-app/immich.git
synced 2025-01-25 05:02:46 +01:00
f55b3add80
Co-authored-by: Thomas Way <thomas@6f.io>
13 lines
358 B
TypeScript
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');
|
|
}
|