Skip to content

Commit

Permalink
add circa and uncertain for all date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Oct 25, 2016
1 parent 7331ff0 commit 63c1943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ class Zotero.BetterBibTeX.DateParser

if @extended && date.match(@isodate)
return {
extended: date
extended: date.replace(/[~\?]/g, '')
uncertain: (if date.indexOf('?') > 0 then true else undefined)
circa: (if date.indexOf('~') > 0 then true else undefined)
}
Expand Down
17 changes: 11 additions & 6 deletions resource/translators/Better BibLaTeX.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ class DateField

format: (v, suffix = '') ->
_v = {}
for f in ['extended', 'empty', 'year', 'month', 'day']
for f in ['circa', 'uncertain', 'extended', 'empty', 'year', 'month', 'day']
_v[f] = v["#{f}#{suffix}"]

return '' if _v.empty
return _v.extended if v.extended
return "#{_v.year}-#{@pad(_v.month, '00')}-#{@pad(_v.day, '00')}" if _v.year && _v.month && _v.day
return "#{_v.year}-#{@pad(_v.month, '00')}" if _v.year && _v.month
return '' + _v.year
switch
when _v.empty then date = ''
when _v.extended then date = _v.extended
when _v.year && _v.month && _v.day then date = "#{_v.year}-#{@pad(_v.month, '00')}-#{@pad(_v.day, '00')}"
when _v.year && _v.month then date = "#{_v.year}-#{@pad(_v.month, '00')}"
else date = '' + _v.year

date += '~' if Translator.biblatexExtendedDateFormat && _v.circa
date += '?' if Translator.biblatexExtendedDateFormat && _v.uncertain
return date

Reference::requiredFields =
article: ['author', 'title', 'journaltitle', 'year/date']
Expand Down

0 comments on commit 63c1943

Please sign in to comment.