readium / swift-toolkit

A toolkit for ebooks, audiobooks and comics written in Swift
https://readium.org/mobile/
BSD 3-Clause "New" or "Revised" License
274 stars 110 forks source link

handle bad values in dc:date #213

Closed aferditamuriqi closed 6 years ago

aferditamuriqi commented 6 years ago

kotlin issue here https://github.com/readium/kotlin-toolkit/issues/203

iaomw commented 6 years ago

Currently dc:date is treated as optional string, there is no date parsed from the string. @llemeurfr And it's not used anywhere is the code. There shouldn't be any error, also there is no warning.

llemeurfr commented 6 years ago

In https://github.com/readium/webpub-manifest/tree/master/contexts/default#publication-date it is specified that the EPUB "dc:date" should be mapped to the "published" property in the webpub manifest, and exposed by the streamer.

Please verify if this is not the case, and correct it if this is missing. We'll then verify the other metadata which should be present in the webpub manifest.

iaomw commented 6 years ago

It's already exposed as publicationDate, although there is no parsing from String to Date. It's just an optional String. And it's not used anywhere else in the current codebase. Do we need to rename it to published?

if let date = metadataElement["dc:date"].value {
    metadata.publicationDate = date
}
llemeurfr commented 6 years ago

precisions: in EPUB2, in order to represent the date of publication (published), dc:date must have no opf:event attribute (in such a case the dc:date represents another kind of date). There may be several dc:date elements with different opf:event attributes and I found no standard controlled vocab. for this attribute (which is therefore unusable).
in EPUB3, the opf:event attribute is deprecated and there is only one dc:date in the metadata element. Other dates are represented by specialized dcterms date elements. We may map some of them later on.

llemeurfr commented 6 years ago

We have chosen to map the dc:date only if its value is a full date (2018-07-30) or date-time (2018-07-30T10:00:00Z). A year (2018) or year-month (2018-07) is not mapped. A badly formed date neither.

aferditamuriqi commented 6 years ago

closing this issue manually as it was missing the fixing keyword closed with this PR https://github.com/readium/r2-streamer-swift/pull/72