mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-08-03 23:21:36 +00:00
15 lines
336 B
JavaScript
15 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 }
|