Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Date-style attribute with historical dates.
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1440290111

Message started by agl on Aug 22nd, 2015, 8:35pm

Title: Date-style attribute with historical dates.
Post by agl on Aug 22nd, 2015, 8:35pm

Forgive me if I’m missing something obvious!

I’m copying lots of notes/clippings collected down the years into Tinderbox and I want to record the date they were originally made and then be able to sort them (among other things) by that date.

I created a User attribute $NoteDate with Type=date but when, for example, I type: Thu 14 March 2013 18:52 — it gets changed to Thu 27 August 2015 18:52.

If I change $NoteDate to Type=string then TB accepts my input but then my agent(s) don’t recognise the attribute as a date and sort alphabetically instead.

Everything was working fine (using Type=date) until I tried to enter “historical” dates. I wondered if I’d any legacy rules or actions hanging around so I created a fresh new TBX  but I’m having the same problem.

I’m guessing the answer lies in a post by Mark A. at: http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1407791447/3#3  but I fear I’ve not grasped how one might “store the formatted date in a user string attribute and display the latter”.

Title: Re: Date-style attribute with historical dates.
Post by J Fallows on Aug 22nd, 2015, 9:16pm


Quote:
I’m copying lots of notes/clippings collected down the years into Tinderbox and I want to record the date they were originally made and then be able to sort them (among other things) by that date.


To clarify, which original date do you want to use for the sorting?
  - The date when the Tinderbox note itself was originally made? Or
  - The date that the clipping / item was originally made?

That is, if you make a note on January 1, 2010, of a newspaper item published July 1, 2009, which are you looking for as the sorting date?

 If you want to sort on the date when the Tinderbox note was created, fortunately that's easy! When you create a note, an attribute called $Created registers that date and time, and doesn't change.

But if you want to register the newspaper item's date, then you just enter it. Create some attribute called (say) $PublicationDate; enter the date you want; and there is no reason why that should change on its own later on.

I am sure the gurus will straighten me out if I've missed this. But what you're asking should be easy to do.

Title: Re: Date-style attribute with historical dates.
Post by agl on Aug 23rd, 2015, 4:32am

Nice question James! I understand that the TBX creation date option, and I use that often.

In your example; I would likely wish to record both dates as separate attributes and sort from either one!

Say I want to write a note about an article on ‘The United States of Beer’ with a $PublicationDate [Type=date] of Sun 2 August 2015.

If I type in the date in full, i.e. Sun 2 August 2015  Tinderbox changes it to Sun 30 August 2015.

Uh oh… hang on, I think I’ve cracked it!

If I type in the date as 2/8/15 Tinderbox correctly changes it to Sun 2 August 2015.

So all is good!  =)

I couldn’t be happier that I can enter dates in the short form and have Tinderbox convert them for me.

Now I’m merely curious as to what happens when I try to enter dates in the format I’ve elected them to be displayed.  User error?  

Title: Re: Date-style attribute with historical dates.
Post by Mark Anderson on Aug 23rd, 2015, 5:53am

As to @agl's closing question, although all (most!) of us each use dates in one format, there are many formats (more than you'd think). The most obvious difference is the order of day and month. For example, month comes first in the USA, the day first pretty much everywhere else. Though a forward slash seems the most popular segment divider (23/8/02) some countries use full stops (23.8.02) or hyphens (23-8-02).

Thus when you type "Sun 2 August 2015" into a Date-type input box, for instance $StartDate, TB will hope for something in one of your localised date settings. From your sign-off up-thread it looks like you're in UK, like me, so in OS X System Preferences you date formats will probably look like this:



Look carefully at the last row - 'Full:' and notice the comma. If I enter "Sun 2 August 2015" in $StartDate I get "30/08/2015 10:27". But, if I add in the comma used in the 'Full' format e.g. "Sun, 2 August 2015"  then in $StartDate I get "02/08/2015 12:00". Note the time element in the latter - on which I'll comment on further below. If I change 'Sun' to 'Sunday', even with the comma, the parsing breaks again as we're not following a 'known' format and Tinderbox is effectively having to guess our meaning. 'Sun 2' or 'Sunday' coerced to a number seems to give 30, whict TB gets the month and year parts correct.
[edit]Oops. I just noticed my setting uses the full day name in 'Full'. Thus as per the OS setting, 'Sunday' should work and 'Sun' should fail but here - UK settings - the opposite occurs! I assume this may be a bug (I've reported this, so no one else needs to do so).[/edit]
The example above is based on UK settings. Were I in the US, I might get different results: consider that 6/7/2015 is 7th of June 2015 in the US and the 6th of July elsewhere. You should endeavour to give Tinderbox a date input using formats those defined in your OS locale's data formats. Otherwise, the app will do it's best to guess and - as in the opening setting - sometimes make mistakes.

Time. The OS date formats don't specify a time pre se, although the same panel does define your locale's time format. Here in UK a colon delimits hours, minutes and seconds (12:40:35) - elsewhere it might be something different like a full stop (12.40.35). If you give Tinderbox a valid date but no time element, Tinderbox will append your current system time in h:m:s (though only h:m are displayed) formatted in your locale's time format.

In testing for this answer, I've noticed an oddity re use of the 'Full' date format without a time portion. If I enter "Sun, 2 August 2015" - no time - I get "02/08/2015 12:00" even though the current time is not 12:00. If I input with a time e.g. "Sun, 2 August 2015 10:51" I get "02/08/2015 10:51"

Note that from v6.3.1 you can alter how Date-type attributes display in Key Attributes via $KeyAttributesDateFormat.

I think that's proably enough Date-type trivia to chew on for now.  :)

Title: Re: Date-style attribute with historical dates.
Post by agl on Aug 23rd, 2015, 12:15pm

Thank you Mark for your comprehensive and considered response (as always).

Perhaps I should’ve mentioned this before…

In order to get Tinderbox to display dates the way I wanted, I had previously changed my OS level settings (!) thus:



[System Preferences > Language & Region > Advanced > Dates]

But, with this set-up, Tinderbox doesn’t seem to like me typing historical dates into attribute fields using my system level “Short” format. Hey ho!

As an aside: I’m using the following in my export template:

<span class="meta"><strong>^value($PostDate.format("w d MM y"))^</strong> • ^value($PostDate.format("t"))^</span>

So, the HTML output displays consistently in my preferred format regardless of what format is shown in the TBX attribute.

Now to investigate www.acrobatfaq.com/atbref6/index/Attributes/SystemAttributeList/KeyAttributeDateFormat.html

EDIT: Ha! Time to update eh? I'm running 6.3.0 so no KeyAttributeDateFormat for me... just yet!  :'(

Title: Re: Date-style attribute with historical dates.
Post by Mark Anderson on Aug 23rd, 2015, 12:22pm

I'd suggest setting the OS short format back to the default and trying out $KeyAttributesDateFormat. You'd use the same format string as used in your export template. For better or worse, Tinderbox seems to cope best figuring dates from text input - such as in key attributes - if you use the (default for your locale) OS 'Short' format. In fairness, dates are far more complex to 'guess' from parsing than perhaps imagined - so many small edge cases, especially when you factor in users in different languages.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.