-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Format filter to create formatted date strings #4785
Conversation
Does it allow all the possibilities as described here: https://tiddlywiki.com/#DateFormat ? |
Imo also related to: #4784 |
Yes the support is complete and the filter relies on the same code from
I do not think that should impact whether we want to merge this or not. The correct way to implement #4784 for backwards compatability would be to adapt the underlying methods for date handling in |
@Jermolene any thoughts? I don't have a vested interested in having this in the core beyond the perceived utility of such a filter to users. If we decide not to merge, I am happy to bundle this as a plugin for those that need it. |
I think it would be useful in the core. We do have a lot of requests in the GG and the existing "workaround" is highly sophisticated wikitext, which is hard to remember. |
Thanks @saqimtiaz this is useful. I've also got an implementation of formatDate() as a filter somewhere in my backlog. I took the approach of calling the operator "format", with "date" being one of the suffixes (e.g. |
@Jermolene apologies for the late reply, I had a bunch of things come up unexpectedly at work that are occuping my attention. I favour your idea of a I think If you have the code for this conveniently at hand already then it would be great to get it posted/merged, otherwise I can rework this PR to implement a |
Hi @saqimtiaz I'm afraid I couldn't find the old code; I do usually keep deleted code but not in this case it seems. There wasn't much to it, I think |
@Jermolene no worries. I'll rework this PR in that direction sometime this week. |
Thanks @saqimtiaz |
@Jermolene @pmario PR updated with a |
Thanks @saqimtiaz -- docs would be appreciated when you get a chance. |
Will do. I had just created an issue to put this on my to-do list when I saw this :) |
Thanks @saqimtiaz |
This PR adds an optimized version of a filter I have been using for some time to allow easy creation of formatted date strings. While there are workarounds possible using the
view widget
and wikify, this extends the ability of filters and is often more convenient.Operand: The operand to the filter operator is used as date
format
, consistent with the handling in theView widget
. If the operand is not specified it defaults toYYYY MM DD 0hh:0mm
which is again consistent with the view widget.Suffix: If the suffix
relative
is used, the operand (if any) is ignored and the string is formatted as a relative date.An invalid date string returns no result.
Examples:
[[20200731]asdate[mmm DD]] -> Jul 31
[[20200730]asdate:relative[]] -> 45 hours ago
[[20200730]asdate:relative[mmm DD]] -> 45 hours ago
If there is interest in adding this to the core I can work on docs as well.