diff --git a/content/dateparser.ts b/content/dateparser.ts index 5446d98388..83785c2003 100644 --- a/content/dateparser.ts +++ b/content/dateparser.ts @@ -397,8 +397,11 @@ export function isEDTF(value: string, minuteLevelPrecision = false): boolean { } export function strToISO(str: string): string { - let date = parse(str) - if (date.type === 'interval') date = date.from + return dateToISO(parse(str)) +} + +export function dateToISO(date: ParsedDate): string { + if (date.type === 'interval') return `${dateToISO(date.from)}/${dateToISO(date.to)}` if (typeof date.year !== 'number') return '' diff --git a/translators/bibtex/bibtex.ts b/translators/bibtex/bibtex.ts index 356070ba05..c896531d3b 100644 --- a/translators/bibtex/bibtex.ts +++ b/translators/bibtex/bibtex.ts @@ -7,7 +7,7 @@ import { validItem } from '../../content/ajv' import { valid, label } from '../../gen/items/items' import { wordsToNumbers } from 'words-to-numbers' -import { parse as parseDate, strToISO as strToISODate } from '../../content/dateparser' +import { parse as parseDate, strToISO as strToISODate, dateToISO } from '../../content/dateparser' import { parseBuffer as parsePList } from 'bplist-parser' @@ -387,7 +387,7 @@ export function generateBibTeX(translation: Translation): void { break case 'interval': - ref.add({ name: 'year', value: item.date }) + ref.add({ name: 'year', value: dateToISO(ref.date) }) break case 'date':