Closed MugenLee closed 3 years ago
hi dear SilentVoid13, please take a look it. thank you.
This problem affected the reconstruction of my previous Weekly. The previous weekly only recorded "WW", but Templater couldn't identify it , so the reconstruction is Stagnant.
You can contact me if you have any questions on it.
Looking forward to your reply.
Hey @MugenLee, this isn't a Templater bug, but a moment.js bug. Templater just calls moment.js under the hood, but that's it.
I made a lot of tests and it looks like the MM
part is what makes moment.js go wrong.
<% moment("47", "ww") %> // Correct
<% moment("47-2021", "ww-YYYY") %> // Correct
<% moment("47-11", "ww-MM") %> // Incorrect
<% moment("47-11-2021", "ww-MM-YYYY") %> // Incorrect
<% moment("47-11-2021", "WW-mm-YYYY") %> // Correct
<% moment("47-11-2021-25", "ww-MM-YYYY-DD") %> // Correct, but we need to specify the day
One solution that is a bit ugly but that works is to purposely mistype the format for the month, for example replacing MM
(month) with mm
(minutes). This allows you to ignore the month part.
I tried searching for someone that already had this bug with moment, but couldn't find anything.
TLDR: You can make it work by replacing
<% tp.date.weekday("ww[W]YYYY-MM-DD", 0, tp.file.title, "ww-MM-YYYY") %>
with:
<% tp.date.weekday("ww[W]YYYY-MM-DD", 0, tp.file.title, "ww-mm-YYYY") %>
Closing this, since this isn't a templater bug. You can open an issue on the moment.js github if you wish.
wow, thank you for you answer this
After reading your explanation, I understand, it turns out that this is an error of moment.js Because it has nothing to do with TP, please close it Let me study it again, the solution ideas and solutions you put forward are very informative, thank you again
SilentVoid13 @.***> 于2021年9月29日周三 下午6:31写道:
Hey @MugenLee https://github.com/MugenLee, this isn't a Templater bug, but a moment.js bug. Templater just calls moment.js under the hood, but that's it.
I made a lot of tests and it looks like the MM part is what makes moment.js go wrong.
<% moment("47", "ww") %> // Correct<% moment("47-2021", "ww-YYYY") %> // Correct<% moment("47-25", "ww-DD") %> // Correct<% moment("47-11", "ww-MM") %> // Incorrect<% moment("47-11-2021", "ww-MM-YYYY") %> // Incorrect<% moment("47-11-2021", "WW-mm-YYYY") %> // Correct<% moment("47-11-2021-25", "ww-MM-YYYY-DD") %> // Correct, but we need to specify the day
One solution that is a bit ugly but that works is to purposely mistype the format for the month, for example replacing MM (month) with mm (minutes). This allows you to ignore the month part. I tried searching for someone that already had this bug with moment, but couldn't find anything.
TLDR: You can make it work by replacing
<% tp.date.weekday("ww[W]YYYY-MM-DD", 0, tp.file.title, "ww-MM-YYYY") %>
with:
<% tp.date.weekday("ww[W]YYYY-MM-DD", 0, tp.file.title, "ww-mm-YYYY") %>
Closing this, since this isn't a templater bug. You can open an issue on the moment.js github if you wish.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SilentVoid13/Templater/issues/372#issuecomment-930052527, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVWTPE5MVPQU6NEAS7BCU5TUELTHNANCNFSM5ENNQLEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
First, em, sorry my English is not very good, So, please just take a look...
The Bug is that:
when I use "tp.date.weekday" to change my "WeeklyNote", I find it can not support the "Week of Year". whether"WW","Wo","W","ww","wo",or "w"
like this imge: I want to position in "47W", but no matter how I enter it, it is always positioned in the first week of November
But when I add the "day" with moment "DD",it can position in "47W"
I see it than I think it can support the "Week of Year"
So, I think it is a little bug, please take a look it, thank you !