jlegewie/zotfile

Use yyyy-mm-dd as date for PDF extraction

argenos opened this issue · 0 comments

Would it be possible to format the date as yyyy-mm-dd?

var date_str = this.getPref("pdfExtraction.localeDateInNote") ? new Date().toLocaleString() : new Date().toUTCString(),

I can open a PR with the changes, but I'd like to ask what would be the preferred way to handle the preferences:

pref("extensions.zotfile.pdfExtraction.localeDateInNote", true);

Would substituting the existing preference for a string-based one, and substituting the ternary operator above for a switch case be alright?

// where predefined_options can be any of 'locale', 'utc' 'ISO' or 'yyyy-mm-dd' 
pref("extensions.zotfile.pdfExtraction.dateFormat", "<predefined_options>"); 

Or would it be best to pass a different wildcard here, such as {'title': str_title, 'date': date_str, 'isodate': iso_date}:
`

title = this.Utils.str_format(format_title, {'title': str_title, 'date': date_str}),