Simplified and enforced better time parsing from filename and/or fullpath of the file.
1.1 Use only 1 regex instead of 2
1.2 Predict certain numbers instead of their amount. E.g. for year, (19[89]\d|20\d\d) is better than (\d\d\d\d), same for month, day, hour, minute, second... This reduces chance for regex to pick invalid numbers from filename/filepath
1.3 Simplified code
Added few more tests
Slight deduplication for local variable.
All tests pass, also added 2 benchmark functions (they can be removed as per your request).
Please let me know what you think. P.S. The way immich-go parses datetime from filename/path is just awesome :heart:
This PR does the following:
(19[89]\d|20\d\d)
is better than(\d\d\d\d)
, same for month, day, hour, minute, second... This reduces chance for regex to pick invalid numbers from filename/filepath 1.3 Simplified codelocal
variable.All tests pass, also added 2 benchmark functions (they can be removed as per your request).
Please let me know what you think. P.S. The way
immich-go
parses datetime from filename/path is just awesome :heart: