From 70a7377e229a76aa60302a3e16186c59b7920c47 Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Sat, 16 Mar 2024 12:56:38 +0100 Subject: [PATCH] fixes #2816 --- content/dateparser.ts | 7 +++++-- translators/bibtex/bibtex.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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':