Skip to content

Commit

Permalink
fixes #2816
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Mar 16, 2024
1 parent 679d127 commit 70a7377
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions content/dateparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''

Expand Down
4 changes: 2 additions & 2 deletions translators/bibtex/bibtex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 70a7377

Please sign in to comment.