Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parse ID3v2 timestamps #233

Closed
Serial-ATA opened this issue Jul 11, 2023 · 1 comment · Fixed by #389
Closed

Parse ID3v2 timestamps #233

Serial-ATA opened this issue Jul 11, 2023 · 1 comment · Fixed by #389
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@Serial-ATA
Copy link
Owner

Summary

We could parse timestamps in the following frames: TDEN, TDOR, TDRC, TDRL, TDTG.

Instead of FrameValue::Text, they would now use FrameValue::Timestamp.

The structure is described in the ID3v2.4 frame overview:

The timestamp fields are based on a subset of ISO 8601. When being as precise as possible the format of a time string is yyyy-MM-ddTHH:mm:ss (year, “-”, month, “-”, day, “T”, hour (out of 24), ”:”, minutes, ”:”, seconds), but the precision may be reduced by removing as many time indicators as wanted. Hence valid timestamps are yyyy, yyyy-MM, yyyy-MM-dd, yyyy-MM-ddTHH, yyyy-MM-ddTHH:mm and yyyy-MM-ddTHH:mm:ss. All time stamps are UTC.

API design

pub struct TimestampFrame {
    // Year is required, and ID3v2 does not allow negative years
    pub year: u16,
    pub month: Option<u8>,
    pub day: Option<u8>,
    pub hour: Option<u8>,
    pub minute: Option<u8>,
    pub second: Option<u8>,
}
pub enum FrameValue {
    Timestamp(TimestampFrame),
    /// ...
}
@Serial-ATA Serial-ATA added enhancement New feature or request help wanted Extra attention is needed labels Jul 11, 2023
@uklotzde
Copy link
Contributor

uklotzde commented Oct 1, 2023

Leading zeros in month/day fields are often omitted or replaced by space(s). The parser should tolerate those violations from the standard, because they are very common.

If these recoverable errors could be detected easily then ParsingMode::Strict might reject them. If that would result in 2 different implementations than it's probably not worth the effort.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants