typst / hayagriva

Rusty bibliography management.
Apache License 2.0
314 stars 47 forks source link

Year support for non-quad dates #81

Closed iandol closed 10 months ago

iandol commented 10 months ago

I tried to use the following BibTeX entry:

@Book{lucretius50bce,
author = {Lucretius}, 
title = {On the Nature of Things}, 
year = {50 BCE}, }

And Typst chokes on it, asking on discord it appears a hayagriva limitation. Making it {0050 BCE} and parsing can continue. Supporting non-quad years would be great!

JakobSachs commented 10 months ago

I was able to replicate the file aswell, the error occurs also simply with a year = {50} or any number with more or less then 4 digits. After taking a dive through the source code it seems to be an biblatex related issue, tho a fix in that library might require a change in src/types/time.rs:

/// Parse a string with a plus/minus and one to four digits into an integer.
fn parse_year(s: &mut Scanner) -> Result<i32, DateError> {
    parse_int(s, 1..=4).ok_or(DateError::UnknownFormat) // change the 4..=4 range to 1..=4 
}
reknih commented 10 months ago

I allowed an era marker in the year field if no sign (+, -) is specified. The year 0 CE/BCE does not exist. Hayagriva needs no parsing fixes since it is supposed to accept ISO standard dates which do not specify era markers, instead, the year 2 BCE is -0001 or -01.