Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Season ranges should be exported as pseudo-months (13-16, or 21-24) #860

Closed
njbart opened this issue Dec 30, 2017 · 45 comments
Closed

Season ranges should be exported as pseudo-months (13-16, or 21-24) #860

njbart opened this issue Dec 30, 2017 · 45 comments
Labels

Comments

@njbart
Copy link
Contributor

njbart commented Dec 30, 2017

The CSL specs allow just one season element per date, so season ranges cannot be expressed in (specs-compliant) CSL JSON. The workaround used by citeproc-js, and adopted as of recently by pandoc-citeproc, is to use pseudo-months instead. citeproc-js has been using 13 to 16; pandoc-citeproc accepts these, and in addition the more ISO8601/EDTF-like 21 to 24.

It would be great if BBT could export season ranges entered in Zotero date fields, such as Summer 2015 - Winter 2016, or 2015-22/2016-24 to CSL JSON as either, e.g.,

"issued": { "date-parts": [[2015, 14], [2016, 16]] }

or

"issued": { "date-parts": [[2015, 22], [2016, 24]] }

… whichever version you prefer.

Of course this should be used for season ranges only – for point dates containing a season, BBT should continue using the season element.

The correct way to export season ranges to biblatex is to use its native ISO8601/EDTF format, e.g.:

date = {2015-22/2016-24}

For pandoc’s CSL YAML format, the expected output is:

  issued:
  - year: 2015
    season: 2
  - year: 2016
    season: 4
@retorquere
Copy link
Owner

wait -- CSL YAML and CSL JSON differ structurally? I thought they were the same except the delivery format.

@retorquere
Copy link
Owner

Can you get me a source reference by way of a BBT error report?

@blip-bloop
Copy link
Collaborator

🤖 this is your friendly neighborhood build bot announcing test build 5224 ("season ranges").

@retorquere
Copy link
Owner

So what would the CSL representation of "Summer 2017 - May 2018" be? Is there documentation of the allowed formats?

CSL YAML supports both the year-season and the date-parts structure, no? I'd rather keep it all the same if possible.

@njbart
Copy link
Contributor Author

njbart commented Dec 30, 2017

Sample: Report ID HD5D2RMI

wait -- CSL YAML and CSL JSON differ structurally?

I’m afraid so. For clarity, the CSL YAML we’re dealing with should probably better referred to as “pandoc CSL YAML” – the in-field markup is different, and so are the date formats.

pandoc-citeproc seems to be able to parse most dates in the citeproc-js CSL JSON format when delivered as YAML, but has also introduced, I suppose for better readability, its own date format with year, month, date elements.

For me personally, pandoc CSL YAML season ranges are of secondary importance (after all, pandoc-citeproc can be used to convert CSL JSON to pandoc CSL YAML), so you might as well choose not to implement this straight away – and hope for a speedy introduction of EDTF dates for CSL JSON and YAML, which would of course make this whole exercise unnecessary.

@retorquere
Copy link
Owner

retorquere commented Dec 30, 2017

wait -- CSL YAML and CSL JSON differ structurally?

I’m afraid so. For clarity, the CSL YAML we’re dealing with should probably better referred to as “pandoc CSL YAML” – the in-field markup is different, and so are the date formats.

I knew about the in-field markup, but it was my understanding that CSL-YAML supported both date formats -- both the more readable format, and the admittedly less-than-great CSL-JSON format. If that is true this simplifies the exporters because I can (and currently do) use common infrastructure for both.

Just so I have things clear for the CSL-JSON case:

  • Summer 1969 parses to { "date-parts": [ [ 1969 ] ], "season": 2 }
  • Summer 1969 - Autumn 1969 parses to { "date-parts": [ [ 1969, 14 ], [ 1969, 15 ] ] }
  • Summer 1969 - December 1970 parses to { "date-parts": [ [ 1969, 14 ], [ 1970, 12 ] ] }?

Would the general rule just be "season point-dates get a season field, ranges (even if they have a season) always get only date-parts with a pseudo-month?'

@retorquere
Copy link
Owner

retorquere commented Dec 30, 2017

BBT uses the numeric format for seasons as per https://github.com/citation-style-language/schema/blob/master/csl-data.json#L214

@retorquere
Copy link
Owner

Should 2017-23/2017-24 have been recognised as a date range? edtf.js doesn't grok the /.

retorquere added a commit that referenced this issue Dec 30, 2017
@retorquere retorquere changed the title Season ranges should be exported as pseudo-months (13–16, or 21–24) Season ranges should be exported as pseudo-months (13-16, or 21-24) Dec 30, 2017
@retorquere
Copy link
Owner

So I'm going for 13 to 16 rather than 21 to 24 for wider compatibility.

@retorquere
Copy link
Owner

(NM on 2017-23/2017-24, I've re-enabled an exception path I had disabled to recognise ranges formatted this way)

retorquere added a commit that referenced this issue Dec 30, 2017
@njbart
Copy link
Contributor Author

njbart commented Dec 30, 2017

Just so I have things clear for the CSL-JSON case:

Summer 1969 parses to { "date-parts": [ [ 1969 ] ], "season": 2 }
Summer 1969 - Autumn 1969 parses to { "date-parts": [ [ 1969, 14 ], [ 1969, 15 ] ] }
Summer 1969 - December 1970 parses to { "date-parts": [ [ 1969, 14 ], [ 1970, 12 ] ] }?

All yes. (It never occurred to me that someone might want to mix months and seasons in a date range, but there seems to be nothing in the 2016 ISO 8601 working draft that would forbid this, and it appears to work as expected with pandoc-citeproc, at least when using chicago-author-date.csl.)

To be clear about generic vs. pandoc CSL YAML: the only kind of date pandoc-citeproc cannot parse from generic CSL YAML is a season range with seasons represented as pseudo-months. If you feel you’d rather want to stick to generic CSL YAML (generic wrt dates) for BBT, we could also try to get pandoc-citeproc fixed to accept pseudo-months here.

retorquere added a commit that referenced this issue Dec 30, 2017
@retorquere
Copy link
Owner

No, if pandoc-csl-yaml expects season ranges as season fields, that can be done. AFAICT, pandoc is the only consumer of csl-yaml, might as well cater to its needs.

@blip-bloop
Copy link
Collaborator

🤖 this is your friendly neighborhood build bot announcing test build 5228 ("test case for #860").

@retorquere
Copy link
Owner

Just to be clear: the csl-yaml should look like this, correct?

---
id: SeasonrangesEDTF2017
issued:
- season: 3
  year: 2017
- season: 4
  year: 2017
original-date:
- season: 1
  year: 2015
- season: 2
  year: 2016

@njbart
Copy link
Contributor Author

njbart commented Dec 30, 2017

Correct.

@retorquere
Copy link
Owner

ugh, this touches csl-yaml date handling more generally. What are the accepted date denotations for csl-yaml?

@njbart
Copy link
Contributor Author

njbart commented Dec 30, 2017

The output from pandoc-citeproc -y suggests the following:

---
references:
- id: :2011
  type: webpage
  issued:
  - year: '2011'
    month: '11'
    season: '1'
    day: '30'
    circa: '1'
  - year: '2012'
    month: '12'
    season: '1'
    day: '31'
    circa: '1'
...

… so it’s more ISO8601/EDTF-like, with separate season and circa elements for start and end dates.

@retorquere
Copy link
Owner

Then perhaps it isn't according to the WD 2016-02-16 that EDTF.js implements ¯\_(ツ)_/¯. If I put that in EDTF.js it complains about the slash.

@njbart
Copy link
Contributor Author

njbart commented Dec 31, 2017

Then perhaps it isn't according to the WD 2016-02-16 that EDTF.js implements

Well, no. From https://www.loc.gov/standards/datetime/ISO_DIS%208601-2.pdf (ISO/DIS 8601-2:2016(e), 2016-10-26; this passage unchanged from the 2016-02-16 version except for section numbering):

“4.7 Divisions of a year
For a year-and-month expression (e.g. 1984-04) the month component may take on values of 21 or above (in place of a month value, 01 through 12). These values signify a division of a year (e.g. “the season Spring”).
4.7.1 Level 1
The values 21, 22, 23, 24 may be used to signify ' Spring', 'Summer', 'Autumn', 'Winter', respectively. Format: YYYY-SS
Example:
· 2001-21 (Spring, 2001)”

So seasons should be treated just like months. Looks like an EDTF.js bug to me.

@retorquere
Copy link
Owner

const edtf = require('edtf')
console.log(edtf('0011-21/0012-22'))

gives

Error: invalid syntax at line 1 col 8:

  0011-21/0012-22
         ^
Unexpected "/"
 for "0011-21/0012-22"

@retorquere
Copy link
Owner

EDTF.js has no issue with the individual dates though. It has a problem with the range.

@njbart
Copy link
Contributor Author

njbart commented Dec 31, 2017

I’d maintain that since year-month ranges are valid EDTF, so are year-season ranges.

@retorquere
Copy link
Owner

I'm not contesting that -- I'm just reporting what I see happening when EDTF.js is passed these dates. I can't find the part of the spec that talks about date ranges at all, so I don't know what the spec says about this.

@njbart
Copy link
Contributor Author

njbart commented Dec 31, 2017

I think it’s mainly in https://www.loc.gov/standards/datetime/ISO_DIS%208601-2.pdf: 4.4.4.1 Representations of time intervals identified by start and end, and 4.4.5 Representations other than complete. I’d agree it’s not easy to find, but I think it’s uncontroversial that YYYY-MM/YYYY-MM is valid, and if it is, then YYYY-SS/YYYY-SS must be valid, too.

Out of curiosity: does EDTF.js accept season ranges when using EDTF level 2?

@retorquere
Copy link
Owner

I don't think so because without further config, EDTF.js defaults to the highest supported spec (IIRC).

@njbart
Copy link
Contributor Author

njbart commented Jan 1, 2018

Test build 5241 seems to export ISO 8601/EDTF season ranges to CSL alright – so it would seem you’re bypassing EDTF.js here, right?

Would you feel it’s still worthwhile to file a bug report with EDTF.js? If so, would you be willing to do that – you might be able to explain more clearly how exactly BBT is using EDTF.js?

One more glitch, too: year 0 (ISO) is year -1 (CSL), year -1 (ISO) is year -2 (CSL), and so on.

(CSL uses, quite awkwardly, - as a shorthand for BCE, and has no year zero.)

5241 exports 0000-01/0000-12 as "issued": { "date-parts": [[-1, 1], [-1, 12]] } (correct), but maps 0000-21/0000-24 to "issued": { "date-parts": [[0, 13], [0, 16]] } – this should be "issued": { "date-parts": [[-1, 13], [-1, 16]] } (and analogously for all negative years).

@retorquere
Copy link
Owner

Test build 5241 seems to export ISO 8601/EDTF season ranges to CSL alright – so it would seem you’re bypassing EDTF.js here, right?

Yep, BBT does a few heuristic stabs before and after it tries EDTF parsing; before are those patterns that confuse EDTF.js, after are those for when both the early heuristics and EDTF.js fail; the season ranges get caught by the after phase.

Would you feel it’s still worthwhile to file a bug report with EDTF.js? If so, would you be willing to do that – you might be able to explain more clearly how exactly BBT is using EDTF.js?

Check: inukshuk/edtf.js#12

5241 exports 0000-01/0000-12 as "issued": { "date-parts": [[-1, 1], [-1, 12]] } (correct), but maps 0000-21/0000-24 to "issued": { "date-parts": [[0, 13], [0, 16]] } – this should be "issued": { "date-parts": [[-1, 13], [-1, 16]] } (and analogously for all negative years).

Right, I think I've found the cause of that.

@blip-bloop
Copy link
Collaborator

🤖 this is your friendly neighborhood build bot announcing test build 5252 ("year zero").

@retorquere
Copy link
Owner

5252 fixes the seasons-BCE problem but also a bug with year zero in biblatex.

@blip-bloop
Copy link
Collaborator

🤖 this is your friendly neighborhood build bot announcing test build 5253 ("dateparser").

@njbart
Copy link
Contributor Author

njbart commented Jan 1, 2018

Great. I haven’t been able to spot any further problems so far.

@lock
Copy link

lock bot commented Mar 9, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked and limited conversation to collaborators Mar 9, 2018
@label-gun label-gun bot reopened this Mar 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants