NotePlan / NotePlan/plugins

Templating: week number in templates should use NP API to get NP week, not isoWeek

Open
#529 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
204
Forks
82
Avg merge
22h 27m
Merged PRs (30d)
3

Description

There are convenience functions in templates that get the weekNumber, e.g.

  weekNumber(pivotDate = '') {

@EduardMe has added functionality to get the NP week number instead, since iso may or may not match what you see in your NP interface, depending on what day you pick for the beginning of a week.

For example, here's how I told a user recently to do it:

---
title: Weekly Note Template Tag
---
Using now/today, no matter where you are, this gives you the current weekly note:
[[<%- Calendar.weekYear(new Date()) %>-W<%- Calendar.weekNumber(new Date()) -%>]]
output: 2022-W49

Using week date (this is the best one if you want the weekly note corresponding to a Calendar note which doesn't have to be today):
[[<%- Calendar.weekYear(Editor.note.date) %>-W<%- Calendar.weekNumber(Editor.note.date) -%>]]

Using title (should normally work as above:
[[<%- Calendar.weekYear(new Date(Editor.note.title)) %>-W<%- Calendar.weekNumber(new Date(Editor.note.title)) -%>]]

@jgclark You deal with these kinds of things more than I do. What other things like weekNumber should be fixed/added to the templating date module to give users access to this info?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.