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

Deprecate custom_datetime #94

Open
nishantwrp opened this issue Sep 15, 2024 · 4 comments
Open

Deprecate custom_datetime #94

nishantwrp opened this issue Sep 15, 2024 · 4 comments
Assignees

Comments

@nishantwrp
Copy link
Collaborator

  • Mark custom_datetime as deprecated in favour of {{ datetime format="[]YYYY[-]MM[-]DD[ ]HH[:]mm[:]ss" }}
  • (Optional - Non blocking for 3.0.0) Show a one-time deprecation notice if anyone uses custom_datetime.
@nishantwrp nishantwrp self-assigned this Sep 15, 2024
@janklostermann
Copy link

This plugin in v2.4.0 on Windows cannot handle the formatting that you proposed as favorable: {{ datetime format="[]YYYY[-]MM[-]DD[ ]HH[:]mm[:]ss" }}

It throws an error:

(In plugin: Templates)

There was an error parsing that template, please review it and try again.

TypeError: (lookupProperty(...) || (depth0 && lookupProperty(...) || container.hooks.helperMissing).call is not a function

Could it be that this functionality has not been developed yet and your issue is a weired kind of a feature request?

@janklostermann
Copy link

I would desire a more general date formatting option as well, that does not only work for datetime through #custom_datetime but works for all variables of type date.

@janklostermann
Copy link

janklostermann commented Oct 23, 2024

Handlebar.js helper could be the way to go (as Handlebar.js is the underlying template engine).
The most primitive solution would be something across these lines:

Handlebars.registerHelper('YYYY', function (date) {
  const d= new Date(date);
  const year = d.getFullYear();
	return year
})

with template definition like

---
 start: date
---

# Start of Note
{{YYYY start}}

with startconfigured as "1923-01-01" at note creation
would produce:


Start of Note

1923


The easiest implementation would be a config field in the plugins config, where (power) users could define these Helpers in JavaScript through a text field. And yes, I am aware, that this could open up security concerns with unsafe code snippets, and also significant debugging problems. Maybe through a testing like on the Handlebar Playground before saving as new config, these issues could become less problematic.

@janklostermann
Copy link

  • Mark custom_datetime as deprecated in favour of {{ datetime format="[]YYYY[-]MM[-]DD[ ]HH[:]mm[:]ss" }}
  • (Optional - Non blocking for 3.0.0) Show a one-time deprecation notice if anyone uses custom_datetime.

Sorry nishantwrp, only now I realize that this was a note by yourself as the maintainer/developer of that plugin.
Thanks for all your work.
I am looking forward for such generalization. Please go the full way for custom-defined date / time variables as well.

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

No branches or pull requests

2 participants