How does one export the day of the month from Zotero to BibTeX?
Hi All
When I export from Zotero to BibTeX, I need the day of the month to be exported, because I need it with the month and year in the references. This is because I am citing reports from several organisations that come out daily or weekly. Using Better BibTeX, putting this in the Postscript:
reference.add({name: 'date', value: item.date});
Gives me this in the *.bib file:
date = {2020-07-04}
So, that means that the day of the month can be exported, but I do not know how to extract it from "2020-07-04". Unfortunately, I do not know JavaScript, but I guess that I can hack my way around it with a bit of help. I need one of the following:
(1) The details of a function in Zotero that extracts the day of the month from item.date.
(2) The details of a function in Better BibTeX that extracts the day of the month from item.date.
(3) What is "2020-07-04" within Zotero/Better BibTeX before it gets exported: a string or an array? Could something like item.date.split be used to break up the date so I can get at the day of the month?
(4) A JavaScript function that I can use to extract the day of the month from "2020-07-04".
I am dealing with an old and buggy citation style in LaTeX (for a chapter in a book), so I need to produce something like:
month = "4~" # jul,
year = 2020,
If I could just get the day of the week, I think that I could put together the JavaScript snippet to use in Better BibTeX's Postscript.
I have trawled through a lot of documentation and source code, but I have not been able to find the solution, so I hope that one of you can help me.
Thank you
Antony
When I export from Zotero to BibTeX, I need the day of the month to be exported, because I need it with the month and year in the references. This is because I am citing reports from several organisations that come out daily or weekly. Using Better BibTeX, putting this in the Postscript:
reference.add({name: 'date', value: item.date});
Gives me this in the *.bib file:
date = {2020-07-04}
So, that means that the day of the month can be exported, but I do not know how to extract it from "2020-07-04". Unfortunately, I do not know JavaScript, but I guess that I can hack my way around it with a bit of help. I need one of the following:
(1) The details of a function in Zotero that extracts the day of the month from item.date.
(2) The details of a function in Better BibTeX that extracts the day of the month from item.date.
(3) What is "2020-07-04" within Zotero/Better BibTeX before it gets exported: a string or an array? Could something like item.date.split be used to break up the date so I can get at the day of the month?
(4) A JavaScript function that I can use to extract the day of the month from "2020-07-04".
I am dealing with an old and buggy citation style in LaTeX (for a chapter in a book), so I need to produce something like:
month = "4~" # jul,
year = 2020,
If I could just get the day of the week, I think that I could put together the JavaScript snippet to use in Better BibTeX's Postscript.
I have trawled through a lot of documentation and source code, but I have not been able to find the solution, so I hope that one of you can help me.
Thank you
Antony
reference.add({ name: 'month', bibtex: '"4~" # jul' })
to output exactly that. You can use the BBT dateparser or Zotero's dateparser to fetch the DOM from the raw date text.Thank you very much for your prompt response, but where do I find documentation on either of the dateparsers?
Thank you
Antony
The BBT dateparser returns dates as objects with the following properties:
this property determines what the rest of the object will look like:
year
, may have amonth
, but only if it has a year, and may have a day, but only when it has a month & year. It may have propertiesapproximate
and/oruncertain
year
and aseason
from
andto
, each being dates of type ‘date’, ‘season’ or ‘open’dates
, which will be a list of dates of type ‘date’, ‘season’, ‘interval’ or ‘verbatim’verbatim
So in your case you could do something like (untested)
Excellent, thank you very much. I wanted the day of the month.
I found that reference.has.month does not seem to work, but I think that it is redundant in any case, because of the use of date.day in the following if statement: I only need the code snippet to run if there is a day of the month. The following works for me:
if (translator.BetterBibTeX) {
const date = Zotero.BetterBibTeX.parseDate(item.date);
if (date.type === 'date' && date.day) {
const month = [ null, 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ][date.month]
reference.add({ name: 'month', bibtex: `"${date.day}~" # ${month}` })
}
Regards
Antony
I have added the following issue on Github:
reference.has.month does not seem to work #1564
I hope that I did it correctly, because I have never done it before.
Thank you
Antony