isaaclyman / novel-word-count-obsidian

Obsidian plugin. Displays a word count or other statistic for each file, folder and vault in the File Explorer pane.
https://obsidian.md/plugins?id=novel-word-count
MIT License
82 stars 8 forks source link

Option to choose a date format? #70

Closed sbsamarski closed 8 months ago

sbsamarski commented 9 months ago

Problem

I am using the plugin to show updated dates next to the notes, and it's great for that. I tinkered with the css file to change the size and opacity of font as well. The issue I have is the date format. I'm from Europe and the dates the plugin shows are fixed in mm/dd/yyyy format. I use Windows 11, with dd.mm.yyyy set as the OS regional date format.

Idea

Is it possible for the plugin to follow the OS regional date format settings? Or at least offer a choice between the most common date formats, such as mm/dd/yyyy, dd/mm/yyyy and yyyy/mm/dd?

isaaclyman commented 9 months ago

See also https://github.com/isaaclyman/novel-word-count-obsidian/issues/65#issuecomment-1830556858. I'll follow up with the Obsidian team and see if there's a way to expose the user's preferred locale via Electron.

(Research note: see https://github.com/obsidianmd/obsidian-api/issues/6)

sbsamarski commented 9 months ago

Thanks. Even a simple date format setting with 3 most common formats would do just fine.

isaaclyman commented 9 months ago

I really want to avoid introducing new settings for things that could be detected automatically. It's not just dates, number separators have been an issue as well.

When you have a moment, would you mind updating your plugin to version 3.0.1 (just released) and seeing if that helps? And if not, could you turn on Debug Mode, open the dev console in Obsidian (View > Toggle Developer Tools) and find the line that looks like this?

novel-word-count: Detected locales: [en-US]

I'm interested to know what locale is being detected on your machine.

sbsamarski commented 9 months ago

OK, I updated it and did it all, but there's no such a line at all. There are 5-6 other lines from the plugin, but not that one about the locales.

BTW, if needed, my "Country or region" (it's written that way in Windows settings) is set to UK and the "Regional format" to English (Europe). The date format is DD-MMM-YYYY.

I'm not sure how that detection would work because, for example, in Windows it's not that simple as just choosing a locale. One can set a region to one country, a language to another, and a date format to something completely different. Windows usually offers a few different date format choices for each selected region.

isaaclyman commented 9 months ago

Can you please confirm:

sbsamarski commented 9 months ago

I'm sorry, I don't see any View menu. But I can open Developer Tools with Ctrl+Shift+I and go to Console menu where there is a list of commands executed, and filter it with "novel". There is a list of 8 command there, in this order:

[refreshAllCounts](novel-word-count: refreshAllCounts) novel-word-count|getAllFileCounts: 124.8740234375 ms novel-word-count: [layout-change] hook fired novel-word-count: container is clean, updating display novel-word-count: Setting display counts for 37753 fileItems novel-word-count|updateDisplayedCounts [ALL]: 22473.77294921875 ms novel-word-count: Setting display counts for 37753 fileItems novel-word-count|updateDisplayedCounts [ALL]: 20449.329833984375 ms

No novel-word-count: initialize. Yes, I'm on the latest version, with plugin's debug mode turned on.

Could it be because no word count option has been enabled, but only to show the updated date for notes and only the note count for folders?

Btw, there are little less than 2800 notes in total and maybe 15 folders.

isaaclyman commented 9 months ago

That's the right place. The initialize and Detected locales logs would be toward the top of your logs; you may need to scroll up and/or restart Obsidian and/or disable and reenable the plugin itself.

sbsamarski commented 9 months ago

Nope. I disabled the plugin, restarted Obsidian, enabled the plugin with the same options, restarted Obsidian, and I get the same lines with slightly different times.

Btw, I see it takes 2 minutes for the plugin to count everything, during which it freezes Obsidian. Imo, there's no need to process ALL the resource files, no need to show their dates. Only the notes matter. In this case it's about processing 37,753 files in total vs less than 2800 note files. If the plugin counted only notes it would probably take just 10 sec instead of 120.

isaaclyman commented 9 months ago

2 minutes is very excessive. My test vault has thousands of files, millions of words, and counts in under a second. What kind of computer are you on?

If you're not seeing the initial startup logs from the plugin, I'm not sure what to do here. Your logs are getting lost somehow.

sbsamarski commented 9 months ago

Ok, thanks. I don't know really what to do if the logs are getting lost.

Yes, there is some issue with the notes. I imported them from Evernote with Yarle, but it messed up the links format in some way (adding triple brackets, which might slow everything), so Obsidian also takes 45 sec to start. I think the developer is fixing the issue and should release the update very soon, and I will reimport all the notes, and try the above again. I'll let you know what happens, hopefully the line with locale will show.

isaaclyman commented 9 months ago

Okay. Let me know what happens, I want to get this fixed for you and other users.

In the meantime, just to solve the date issue, do you have another vault you could test with? Even a new vault with one file might give us some meaningful data, if the logs would come through for it.

sbsamarski commented 9 months ago

Ok, I'll do that.

sbsamarski commented 9 months ago

Ok, there are many more lines now. The first one is this: novel-word-count: Detected locales: [en-US]

Just to mention it again - I use Windows 11. My "Country or region" (it's written that way in Windows settings) is set to UK and the "Regional format" to English (Europe). The date format is DD-MMM-YYYY.

Windows can have different date formats, independent from the Country and Region settings.

isaaclyman commented 9 months ago

Understood. My expectation is that the detected locale would be en-GB, which would format the date as dd/mm/yyyy. I'll do some more research and see if there's a more reliable way to get the system locale.

isaaclyman commented 8 months ago

Sorry for the wait. Long story short, there is not a way to get the correct locale in Obsidian/Electron. I've updated the formatting of the dates to YYYY/MM/DD, which is unambiguous in every locale. This doesn't seem worth its own setting to me, but we'll see how many complaints I get.

Released as v3.2.0.

sbsamarski commented 8 months ago

YYYY-MM-DD is Obsidian's default date format (and ISO standard format), which many people actually choose to use, so I think that's perfectly fine. Thanks for the update!