feat(date-guess): recognise YY-MM-DD HH-MM-SS Synology export filenames

The 0525.mov-style export from Synology Photos uses 2-digit years, which
the existing patterns ignored (all required \d{4}). Result: filename
gave no signal, suggestion fell through to the YYYY/MM folder layout and
snapped to day 15. The explicit HH-MM-SS half rules out random digit
triples, so we trust YY → 2000+YY for this specific shape and surface
the actual capture time, not noon.
This commit is contained in:
Claudio
2026-05-11 20:56:47 +02:00
parent 7a1c6b618b
commit 356062ead3
2 changed files with 51 additions and 0 deletions

View File

@@ -78,6 +78,32 @@ function guessFromString(
): DateGuess | null {
if (!input) return null
// Day+time: YY-MM-DD HH-MM-SS — Synology Photos export. The explicit
// HH-MM-SS half is what makes the 2-digit year safe to trust; a random
// digit triple won't satisfy the hour/minute/second range checks below.
// YY → 2000+YY (this format is a recent export convention).
const synology = input.match(
/(?<!\d)(\d{2})-(\d{2})-(\d{2})[\s_](\d{2})-(\d{2})-(\d{2})(?!\d)/,
)
if (synology) {
const yy = +synology[1], mm = +synology[2], dd = +synology[3]
const hh = +synology[4], mi = +synology[5], se = +synology[6]
if (hh < 24 && mi < 60 && se < 60) {
const date = makeDate(2000 + yy, mm, dd)
if (date) {
date.setHours(hh, mi, se, 0)
return {
date,
confidence: 'high',
matched:
`${synology[1]}-${synology[2]}-${synology[3]} ` +
`${synology[4]}:${synology[5]}:${synology[6]}`,
source,
}
}
}
}
// Day-level: YYYYMMDD run bounded by non-digits ─ `IMG_20190712_153045`.
const compact = input.match(/(?<!\d)(\d{4})(\d{2})(\d{2})(?!\d)/)
if (compact) {