Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unable to create file" error when using ISO week "gggg-[W]WW" #79

Open
mturilin opened this issue Nov 30, 2021 · 3 comments
Open

"Unable to create file" error when using ISO week "gggg-[W]WW" #79

mturilin opened this issue Nov 30, 2021 · 3 comments

Comments

@mturilin
Copy link

@mturilin mturilin commented Nov 30, 2021

Screen Shot 2021-11-29 at 5 13 20 PM

  • I set up my weekly file pattern to "gggg-[W]WW"
  • When I click on "Open this week" button I see an error "Unable to create file"

Root cause:
I dug through the source code. The problem that when the app calculates the beginning of the week we should use:

  • ISO week: moment.startOf("isoWeek")
  • Normal week: moment.startOf("week")

Test case:

> window.moment("2021-W47", "gggg-[W]WW", true).startOf("week").format("gggg-[W]WW");
< "2021-W46" // ERROR: expected "2021-W47"

> window.moment("2021-W47", "gggg-[W]WW", true).startOf("isoWeek").format("gggg-[W]WW");
< "2021-W47" // SUCCESS - this is what we should use for ISO weeks

> window.moment("2021-W47", "gggg-[W]ww", true).startOf("week").format("gggg-[W]ww");
< "2021-W47" // Non-ISO week works fine

@liamcain
Copy link
Owner

@liamcain liamcain commented Nov 30, 2021

Yeah, this plugin admittedly could handle ISO dates better. Thanks for the report and the debugging!

A workaround for now is to change your locale using the Calendar plugin. In the Calendar plugin settings, there's a dropdown to change the locale to en-GB which will get respected by Periodic Notes too. Then can keep the format as gggg-[W]ww which will be the same as the ISO week numbers.

But I'll work on getting a real fix in soon!

@WhiteNoiseDev
Copy link

@WhiteNoiseDev WhiteNoiseDev commented Dec 28, 2021

@mturilin shouldn't you use GGGG-[W]WW for complete ISO format? (there may be a difference at the end of the year)

Anyway I have the same problem with GGGG-[W]WW this week. It should be 2021-W52. it's correctly reported here
image

But when I create the I get the Unable to create the file along with
image

Once the files is created, it works fine.

@jkrcma
Copy link

@jkrcma jkrcma commented Jan 3, 2022

Btw using GGGG-[w]WW instead (or without the square brackets GGGG-WW) does work, but such format generates 2021-w52 (or without w) for the current week, which is also wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants