Skip to content

Timestamp parsing fails on dot-separated dates (e.g. YYYY.MM.DD) even in Relaxed mode #647

Closed

Description

@RogueOneEcho

Reproducer

    #[test_log::test]
	fn timestamp_dot_separators() {
		let timestamp = "2024.06.03";

		let parsed_timestamp_strict =
			Timestamp::parse(&mut timestamp.as_bytes(), ParsingMode::Strict);
		assert!(parsed_timestamp_strict.is_err());

		let parsed_timestamp_best_attempt =
			Timestamp::parse(&mut timestamp.as_bytes(), ParsingMode::BestAttempt).unwrap();
		assert_eq!(
			parsed_timestamp_best_attempt,
			Some(Timestamp {
				year: 2024,
				month: Some(6),
				day: Some(3),
				..Timestamp::default()
			})
		);
	}

Summary

Timestamp parsing fails on dot-separated dates (e.g. YYYY.MM.DD) even in Relaxed mode.

It's not uncommon for FLAC files from distributors such as Genie to contain dot separated dates. This is valid for FLAC dates as they are just strings but when lofty converts VORBIS dates to ID3 date fields such as TDRC the Timestamp parser fails with the error: Encountered an invalid timestamp: Timestamp segment contains non-digit characters.

Ideally, the BestAttempt and Relaxed modes would support . as a possible separator.

Related: #462, #466, #452

Relevant source:

const SEPARATORS: [u8; 3] = [b'-', b'T', b':'];

if let Some(sep) = sep {
let byte = content.read_u8()?;
if byte != sep {
if parse_mode == ParsingMode::Strict {
err!(BadTimestamp("Expected a separator"))
}
return Ok(STOP_PARSING);
}
}

Expected behavior

2024.06.03 should be parsed in relaxed and best attempt mode.

Assets

metaflac --export-tags-to=-path/to/track.flac                    
...
DATE=2000.12.01

Activity

  1. added
    bug
    on Apr 19, 2026
  2. Serial-ATA commented on Apr 19, 2026

    @Serial-ATA
    Owner

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions