20 lines
389 B
Go
20 lines
389 B
Go
package mic
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"path/filepath"
|
||
|
|
"regexp"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
const recordingLayout = "2006-01-02-150405"
|
||
|
|
|
||
|
|
var recordingPattern = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}-\d{6}\.wav$`)
|
||
|
|
|
||
|
|
func RecordingFilename(t time.Time) string {
|
||
|
|
return t.Local().Format(recordingLayout) + ".wav"
|
||
|
|
}
|
||
|
|
|
||
|
|
func ValidRecordingFilename(name string) bool {
|
||
|
|
return recordingPattern.MatchString(filepath.Base(name))
|
||
|
|
}
|