Thanks Tony!  I appreciate you taking time to answer a post from a relative 
newcomer in the forum!

Your answer gave me some food for thought...  Any of the built-in filter 
operators which perform date calculations must allow for both timestamp 
strings (such as returned by <<now "[UTC]YYYY0MM0DD0hh0mm0ssXXX">>) and 
actual Date() objects (such as the "modified" or "created" field values), 
same as mine does.  So I looked at code for the "days" operator and saw 
there is a built-in utility function ($tw.utils.parseDate) which 
transparently handles either case.  Not exactly what I was seeking, but 
very helpful nonetheless!

As for your view on JavaScript....  I can partially agree :)  I too prefer 
using built-in functionality whenever feasible.  But on the other hand, 
*somebody* has to write those community plugins, right?

peace,
Nutt

On Thursday, April 16, 2020 at 10:35:33 PM UTC-4, TonyM wrote:
>
> Nutt,
>
> I use date stamps a lot, especially to drive periodical items, for example 
> a weekly-review field with a date stamp becomes due again once the date 
> stamp is older than 7 days. I do not touch javascript.
>
> Here are some quick leads.
>
>    - Set a field to the result of <<now "[UTC]YYYY0MM0DD0hh0mm0ssXXX">>   
>    see <https://tiddlywiki.com/#Date%20Fields> and this 
>    <https://tiddlywiki.com/#now%20Macro>
>    - Use a button to setfield
>    - Use the Date Picker Plugin http://kixam.github.io/TW5-datePicker/
>
> Try this trick if you want to accept simple formatted dates
> <$edit-text field="date-field" field="myconfig" type="date"/>
>
> But then you would be wise to convert these to tiddlywiki date/time serial 
> number to make full use of the days operator and more such as comparing 
> with a system date or today.
>
> *Just ask if you come across some gaps!*
>
> It is my considered view if you are using javascript functions in 
> tiddlywiki rather than its existing methods
>
>    - You are doing it the wrong way
>    - You have discovered a gap that should be considered as a new feature 
>    or a plugin to be developed for the community.
>
>
> Regards
> Tony
>
>
> On Friday, April 17, 2020 at 12:01:35 PM UTC+10, grundyunderhill wrote:
>>
>> Hi all,
>> Is there any way to make TW treat a user-defined field as a timestamp, 
>> like it does for the built-in "created" and "modified" fields?
>>
>> My use case is that I want to capture timestamps of other events (besides 
>> creation and modification), and be able to perform Date-related 
>> calculations against them.  Closest I've come so far is saving a string in 
>> same format as it uses for "modified", and writing a custom filter operator 
>> which calls $tw.Tiddler.fieldModules.modified.parse() to convert string to 
>> Date object.  It works, but I feel like it would be cleaner if I could just 
>> check whether it's a Date already, and ignore everything else...
>>
>> Thanks,
>> Nutt
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b4d40502-2d08-49dc-8092-5e7b9df24a93%40googlegroups.com.

Reply via email to