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

{date.created} - how do I get a user readable form? #157

Open
DrKlipper opened this issue Sep 28, 2023 · 3 comments
Open

{date.created} - how do I get a user readable form? #157

DrKlipper opened this issue Sep 28, 2023 · 3 comments

Comments

@DrKlipper
Copy link

Hi !

Using this <nspages -subns -h1 -r -customTitle="{title} ({date.created})"> results in a very strange datetime output:
grafik
I think it´sthe epoch date or something like that ...

Anyway ... Is there an option to render this as human readable date / time output?
This is pretty useless for a normal User :-)

Dominik

@gturri
Copy link
Owner

gturri commented Sep 28, 2023

you are correct, this is the epoch.

Here are the some difficulties I see in order to display a human readable date:

  • As far as nspages is concerned, this is just an integer that it reads from the metadata and displays as-is: it does not know that it's supposed to represent a timestamp. See e.g. the screenshot below which represent a metadata file (from data/meta/some-page.meta on my filesystem)
    image
  • Besides this, I guess some users might rely on this being a timestamp (could be used for instance to sort on the most recently edited page I guess)
  • Also, there are multiple ways to display human readable dates (I love iso-8601, but some folks prefer a format like 28/09/2023). Let alone displaying or not the hours, minutes, ...

I can think of a few ways to cope with it (eg: considering that every key like date.xxx should be displayed as date (with some fixed formats) provided that some option (eg: -expandMetadataDate) is provided; or creating some kind of DSL so a user could use input like <nspages -customeTitle="{title} toDate({date.created})">), but this would be complicated and brittle. And it may not even be able to fit the need of every users.

I'm thinking of another approach: it would be great if nspages just focuses on display TOC, and some "something else" focuses on making available a metadata like humanReadableDate.created.
Not only would that be aligned with the unix philosophy "Do One Thing And Do It Well", but it could also benefit other plugin that might rely on metadata dates.

That "something else" should likely be a plugin, something like the meta plugin (in the sense that it seems able to insert ad hoc metadata (though perhaps not dynamically)).

That being said, I have no clue if a plugin that would fit your need already exist yet 🤔

@DrKlipper
Copy link
Author

DrKlipper commented Sep 28, 2023

Well ... Having an extra plugin just for showing this date field ... Sounds a little bit overengineer to me ...

toDate({date.created})
Having a simple option which converts the epoch to a simple date (without time) would be totally fine.
This will show a creation date, which is totally fine. I think the main purpose of this view is to get an idea when the page was created. I think having the correct time does not really matter. This can be viewed from the "old revisions" page.

Just me 2 cents ...

@gturri
Copy link
Owner

gturri commented Sep 28, 2023

Thanks for your answer.

I'm afraid it would be not so trivial to implement, but I guess I can let this feature request open so that if someone is interested in this feature and proposes a pull request, I can consider it 🙂

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

No branches or pull requests

2 participants