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

datetime renders as [object Object] #2

Closed
pvlrmnnk opened this issue Dec 30, 2020 · 6 comments
Closed

datetime renders as [object Object] #2

pvlrmnnk opened this issue Dec 30, 2020 · 6 comments

Comments

@pvlrmnnk
Copy link

How to reproduce

  1. Add {{ datetime }} to emplate
  2. Render it in any note, it will print [object Object]

Ecpected result
{{ datetime }} renders as YYYY-MM-DD by default (or any other format).

I think date format should be configurable

@pvlrmnnk
Copy link
Author

I think we need something like https://github.com/e-picas/nunjucks-date-filter

@garyng
Copy link
Owner

garyng commented Dec 31, 2020

It will print [object Object] because datetime is an object, you need to use datetime.now instead.

The builtin datetime provider is very dumb though.. So it might not be what you want. Contributions are welcome!

@garyng
Copy link
Owner

garyng commented Dec 31, 2020

I looked at https://github.com/e-picas/nunjucks-date-filter before, but seems like it's unmaintained for years... I couldn't find a good alternative for now.

@pvlrmnnk
Copy link
Author

pvlrmnnk commented Dec 31, 2020

https://www.npmjs.com/package/nunjucks-date-filter-locale seems to be what i'm looking for
it also supports timezones and locales, which is great

So it might not be what you want. Contributions are welcome!

Ok, i'll setup proper dev env next week and try to add this filter

@garyng
Copy link
Owner

garyng commented Dec 31, 2020

I'll take a look at this too when I have time. We probably need to allow user to configure locale and timezone in the settings page right?

@garyng garyng closed this as completed in 8395da6 Jan 3, 2021
@garyng
Copy link
Owner

garyng commented Jan 3, 2021

Date formatting is now supported! See https://github.com/garyng/obsidian-temple#formatting-with-dateformat-filter

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