mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-08-03 15:11:44 +00:00
14 lines
336 B
JavaScript
14 lines
336 B
JavaScript
/**
|
|
* Normalize ISO-style published dates to the book metadata year format.
|
|
*
|
|
* @param {*} value
|
|
* @returns {*}
|
|
*/
|
|
function normalizePublishedYear(value) {
|
|
if (typeof value !== 'string') return value
|
|
|
|
const match = value.match(/^(\d{4})(?:-|$)/)
|
|
return match ? match[1] : value
|
|
}
|
|
|
|
module.exports = { normalizePublishedYear }
|