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

YAML datetime & any type of Templater date fields are not recognized as field of type 'Date' #928

Open
maximbelyayev opened this issue Aug 2, 2024 · 2 comments
Labels
kind/bug Something isn't working lifecycle/backlog Issues that are ready to be worked on. triage/confirmed Issue is well-defined and understood. Needs to have a priority/* label.

Comments

@maximbelyayev
Copy link

maximbelyayev commented Aug 2, 2024

What happened?

Obsidian Project note templates with YAML datetime properties or any type of YAML date/datetime field generated via Templater are not recognized by Obsidian Project as date/datetime fields when said templates are used to create a note.

In the below image, the right tab is my template which contains the YAML properties I want to test. The left tab is the resulting Obsidian Project table after creating a note via this tab. As you see, only one field (static date) is recognized by Obsidian Projects as a date/datetime field.

Screenshot 2024-08-02 at 11 08 17 AM

For context, I'm using Templater to automatically update date_created and date_modified fields that I want to have.

What did you expect to happen?

I expected date fields ('YYYY-MM-DD') to be recognized by Obsidian projects as a field of type 'Date'.

I expected datetime fields ('YYYY-MM-DD HH:MM') to be recognized by Obsidian projects as a field of type datetime ('Date' with 'Enable time' option automatically selected).

How can we reproduce it (as minimally and precisely as possible)?

Create a template that contains two YAML properties with the following values:

date_test: 2024-08-02
datetime_test: 2024-08-02 12:00

Optionally, also install/enable the Templater plugin and in Templater options, enable "Trigger Templater on new file creation". This is so that when Obsidian Projects creates a new note via a template, any templater code in the template is executed (as described in #889)

Then, add third and fourth YAML properties to the template with the following value:

date_templater_test: <% tp.file.last_modified_date('YYYY-MM-DD') %>
datetime_templater_test: <% tp.file.last_modified_date() %>

Finally, create a new note using said template with these two/four YAML properties and check results in the Obsidian Projects Table view. You will see that date_test is automatically recognized as a date field, whereas datetime_test, date_templater_test, and datetime_templater_test are recognized as 'Text' fields.

Anything else we need to know?

  1. I think for the Templater test fields, because date_templater_test doesn't get recognized but date_test does, it could be that Obsidian projects picks up the Templater code text and sets the field to type text, then only after this field type is set by Obsidian projects does Templater render its code to the datetime. Just a hypothesis

  2. Will the eventual/future feature to change field type fix this issue? In that these fields may still not be recognized by Obsidian projects as date/datetime fields, but I can change the field type and it will force these fields in future notes to conform from text type to date/datetime type.

Plugin version

1.17.4

Obsidian version

1.6.7

OS

macOS

@maximbelyayev maximbelyayev added kind/bug Something isn't working needs-triage Issue needs a triage/* label labels Aug 2, 2024
@maximbelyayev maximbelyayev changed the title YAML datetime & any type of Templater date/datetime fields are not recognized as field of type 'Date' or 'Datetime'. YAML datetime & any type of Templater date fields are not recognized as field of type 'Date' Aug 2, 2024
@Acylation Acylation added triage/confirmed Issue is well-defined and understood. Needs to have a priority/* label. lifecycle/backlog Issues that are ready to be worked on. and removed needs-triage Issue needs a triage/* label labels Aug 5, 2024
@Acylation
Copy link
Collaborator

Link to #889

@theSmokingFrog
Copy link

When you configure the columns prior to creating a task, the fields do get recognised as a date field. Thus wenn the table is empty, create a new column which for example is date_templater_test and set it to date - but it comes with a new issue. Once there is at least a single task having a date everything seems to work.

With that setup, my actual issue comes into play: When creating a note with anything that is not date inside (in my case a Templater expression, but just typing a word also breaks it) of it, Projects View breaks with a RangeError. Project Switch does not work anymore, new Task does not appear, other tasks cannot be modified anymore.

Only way to get everything working again: Close and reopen the View.

The Screenshot below shows the situation directly after creation of the note. The File explorer shows that Note 2 exists, the second row of the Projects Table View is also present.

Probably all happens due to the fact that the Templater Expression is not yet replaced when the Task is parsed.

Screenshot 2024-08-09 at 09 47 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working lifecycle/backlog Issues that are ready to be worked on. triage/confirmed Issue is well-defined and understood. Needs to have a priority/* label.
Projects
None yet
Development

No branches or pull requests

3 participants