Skip to content

Instantly share code, notes, and snippets.

@andreibosco
Last active September 24, 2022 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreibosco/2bf0f3897da8b51640bb2768e8ea61da to your computer and use it in GitHub Desktop.
Save andreibosco/2bf0f3897da8b51640bb2768e8ea61da to your computer and use it in GitHub Desktop.
Zotero Better Bibtex - Postscript to format access date (long format) and url fields on webpage items and setting month field as a number on any item.
if (Translator.BetterBibTeX) {
if (tex.has.month) {
tex.add({ name: 'month', value: tex.date.month});
}
if (zotero.itemType === 'webpage') {
if (zotero.accessDate) {
var customDate = new Date(zotero.accessDate.replace(/\s*T?\d+:\d+:\d+.*/, ''));
var intlCustomDate = new Intl.DateTimeFormat('en-GB', {year: 'numeric', month: 'long', day: 'numeric'}).format(customDate);
tex.add({ name: 'note', value: "(accessed on " + intlCustomDate + ")" });
}
if (zotero.url) {
tex.add({ name: 'howpublished', bibtex: "{Available online: \\url{" + tex.enc_verbatim({value: zotero.url}) + "}}" });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment