gturri / nspages

Plugin for dokuwiki - Display tables of content
http://www.dokuwiki.org/plugin:nspages
GNU General Public License v2.0
25 stars 24 forks source link

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

Open DrKlipper opened 1 year ago

DrKlipper commented 1 year ago

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 commented 1 year ago

you are correct, this is the epoch.

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

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 commented 1 year ago

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 commented 1 year ago

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 🙂