boonya/rtsp-video-recorder

View on GitHub
src/helpers/playlistName.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
export default function playlistName(customValue?: string) {
    if (customValue) {
        return customValue
            .replace(/[:]+/ug, '_')
            .replace(/_+/ug, '_');
    }

    const now = new Date();
    const [date] = now.toISOString().split('T');
    const [time] = now.toTimeString().split(' ');

    return [
        date.replace(/-/ug, '.'),
        time.replace(/:/ug, '.'),
    ].join('-');
}