[tw] Re: Formula 0.2: Functional computing & spreadsheet formulas for TiddlyWiki

Hey, Diego —

Pardon the slow reply.  I've been pretty busy with Real Work since my
convention trip.  I expect to do some more work on formulas this weekend
and will be tracking down the issue.

In the future, please file an issue on the plugin's GitHub
<https://github.com/EvanBalster/TiddlyWikiFormula/issues> if possible!
Makes this stuff easier to keep track of.

On Tuesday, 6 February 2018 15:30:19 UTC-6, Diego Mesa wrote:
>
> Hey Evan,
>
> Sorry if Im missing something, but is
>
> now() and date(12,12,12)
>
> not working?
>
> Thanks!
>
> On Sunday, February 4, 2018 at 2:09:26 AM UTC-6, Evan Balster wrote:
>>
>> Hey, Tony —
>>
>> The tw_date function should do what you want:  It manually turns other
>> things into dates, bypassing the normal "interpretation" mechanism.  It
>> will accept YYYYMMDD dates with each subsequent part being optional.  It
>> might not work on data that have been interpreted as numbers, which can
>> happen with {{transclude}} syntax...  To avoid the interpretation, you can
>> use the "transclude" or "variable" functions to fetch raw, uninterpreted
>> text:
>>
>> ... tw_date(transclude("tiddler", "field")) ...
>>
>> Basically the idea is that all automatic conversion can be bypassed or
>> done manually.
>>
>> The "fall-back" behaviors you're describing would best be implemented
>> with the "iferror" function, which formula doesn't implement yet.  Other
>> than that I advise using some string-related functions to figure out what
>> kind of data you're dealing with.  For example,
>> len(trim(x))==0
>> tells you if some data is blank (ie, only whitespace or nothing at all).
>>
>> I might have to investigate the interoperation problems between formula
>> and condition.
>>
>> On Saturday, 3 February 2018 21:35:13 UTC-6, TonyM wrote:
>>>
>>> Evan,
>>>
>>> Thanks again for your work.
>>>
>>> To the point : *So I suppose I am asking, "can the treatment of empty
>>> or blank date fields be restored?", or could you "tell me a way to treat
>>> such fields to avoid the errors?"*
>>>
>>>
>>> *Date Format*
>>> First, removing the trailing "00" or using 000 does indeed let a date
>>> display correctly THANKYOU
>>> I was erroneously setting dates to one digit short
>>> <$action-setfield$field=date-field $value=<<now >>> YYYY0MM0DD0hh0mm0ss000>>$timestamp=no />
>>> Previously however this was tolerated. As was a date field with only the
>>> date YYYY0MM0DD and other combinations (I have not retested)
>>>
>>> *Blank dates*
>>>
>>> This behaviour has changed, I am now getting these errors below when
>>> previously use of date fields that had empty or a single space in the date
>>> field were tolerated and no result was returned,
>>>
>>> ComputeError: Cannot auto-convert "" to a date!
>>> ComputeError: Cannot auto-convert " " to a date!
>>>
>>> I was using the existence of a date-field to trigger the display, time
>>> stamp or edit of that and other fields
>>>
>>>
>>>    - For example if item-started existed it allows you to "select,
>>>    enter or time stamp the date"  item-started
>>>    - Basically the existence of item-started indicates the tiddler is
>>>    now under disposition management (regardless of its value or not)
>>>    - It also provides the ability to optionally provide a
>>>    item-completed or item-cancelled dates
>>>    - If I accidentally cancelled the item and cleared the
>>>    item-cancelled date, to instead set the completed date, I would have a
>>>    blank cancelled date field.
>>>
>>> *Why permit " " dates*
>>> If I am using the existence of a date field empty or otherwise I use a
>>> filter that includes has[fieldname]
>>> Of note was that this has[fieldname] filter often seemed only to work
>>> when the field existed and was not empty, hence the use of " "
>>>
>>> On example of where formulas was tolerant of blank and space was in the
>>> following, which calculates the number of days between the date-fields
>>> value and today.
>>>
>>> \define daystoday(datefield)
>>> (= days( now(), date( {{!!$datefield$}} ) ) =)
>>> \end
>>>
>>>
>>> Other examples, It is fine for these to return nothing
>>>
>>> (= if(tw_date({{!!$datefield$}})=now(),"Today","Not Today") =)
>>>
>>>
>>> \define showtodayrange(datefield1,datefield2)
>>> <progress value=<<formula "days( date( {{!!$datefield1$}} ) , now() )">>
>>> max=<<formula "days( date( {{!!$datefield1$}} ) , date( {{!!$datefield2$}}
>>> ))">>/>
>>> \end
>>>
>>>
>>> <$if value=(={{!!$datefield$}}=)> >>> Has value (=date({{!!$datefield$}})=) >>> <$set name=indate value= (=date({{!!$datefield$}})=)>
>>> </$if> >>> <$else>
>>>  No Value (={{!!$datefield$}}=)
>>>  <$set name=indate value=(=now()=)> >>> </$else>
>>>
>>> The above also seems broken, using The *Condition* plugin for TiddlyWiki,
>>> version 0.1.0 (disabled or not)
>>>
>>>
>>> *So I suppose I am asking, "can the treatment of empty or blank date fields
>>> be restored?", or could you "tell me a way to treat such fields to avoid
>>> the errors?"*
>>>
>>>
>>>
>>> Tony
>>>
>>>
>>>
>>> On Sunday, February 4, 2018 at 12:54:42 PM UTC+11, Evan Balster wrote:
>>>>
>>>> Hey all —
>>>>
>>>> Formula 0.2.2 is out:  https://evanbalster.com/tiddlywiki/formulas.html
>>>> GitHub:  https://github.com/EvanBalster/TiddlyWikiFormula
>>>>
>>>> Changes:
>>>>
>>>>    - Fixed a bug in the parsing of /* block comments */. // line
>>>>    - Implemented regular expression literals in the JavaScript style:
>>>>    /regex/g
>>>>       - May be used as a Datum
>>>>       <https://evanbalster.com/tiddlywiki/formulas.html#Datum>
>>>>       - When converting strings to regex, both JavaScript and
>>>>       TiddlyWiki styles will be recognized.
>>>>    - Formula errors now mention LET assignments they lie inside.
>>>>    - Formulas as Tag Attributes
>>>>
>>>> <https://evanbalster.com/tiddlywiki/formulas.html#Formulas%20as%20Tag%20Attributes>
>>>>  are
>>>>    now facilitated by a mod using the experimental Mod-Loader Plugin
>>>>    .
>>>>
>>>>
>>>> *Tony* — I fixed some coercion bugs in 0.2.1 but I'm not sure if those
>>>> cover the issues you're reporting.
>>>>
>>>> The blank definitely won't be treated as a date (what would it default
>>>> to, anyway?)
>>>>
>>>> As for the other one, 2017122410592500 isn't quite a valid TiddlyWiki
>>>> date under current semantics.
>>>>
>>>> *2017 12 24 10 59 25 00*
>>>>
>>>> The last bit (milliseconds) should be either 3 digits or completely
>>>> absent.  AFAIK TiddlyWiki dates are never expressed to "centisecond"
>>>> precision so this looks out of place to me.  I'm strict about what Formula
>>>> interprets as a date, because these strings of digits could also be
>>>> numbers.
>>>>
>>>>
>>>> experimentation encouraged!
>>>>
>>>>
>>>> On Friday, 2 February 2018 22:30:02 UTC-6, BurningTreeC wrote:
>>>>>
>>>>> Hi Evan,
>>>>>
>>>>> I've found this *handsontable* library and tried making a basic
>>>>>
>>>>> The docs <https://docs.handsontable.com/0.35.1/Core.html> look
>>>>> promising and the interface is very nice - the license is MIT
>>>>>
>>>>> Simon
>>>>>
>>>>

--
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 post to this group, send email to tiddlywiki@googlegroups.com.
To view this discussion on the web visit