Closed spozer closed 1 year ago
Thanks for the PR. I am currently quite busy, but I will try to review the PR before the weekend.
I just noticed that there is an error when using other locale formats other then 'en' or 'gb'. I will try to fix this.
This adds the option to set a custom date format, like requested in #78 by @iznaut.
I added a
DateFormatter
class, which gets used in theAPIModel
s to format date strings. I also looked up what type of date formats are used by the various APIs, and saved them as variables calledapiDateFormat
. This makes the date formatting more robust, because you don't have to guess the actual date formats.The
DateFormatter
holds the currently set custom date format. This gets updated in themain
- by calling thesetFormat()
function ofDateFormatter
- when the user changes the custom date format in the settings tab.For the settings tab, I added a text field where the user can input a custom date format string. The settings also shows a preview of what the current format will look like.
For the actual date formatting the
DateFormatter
usesmoment.js
. Which is also used and exported byobsidian
itself. But I had some trouble importing it. WithesModuleInterop
set in the compiler config, the type script compiler doesn't like thatobsidian
importsmoment
with a namespace-style import (which is also not compliant with ES6 module spec) like this:So when running
npm run build
the following always results in compiler errors complaining about the namespace-style import ofmoment
inobsidian.ts
:I eventually got it to work with:
I don't know if this is a good way to import it though.