Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Changing date format (Read 4492 times)
luix
Full Member
*
Offline



Posts: 9

Changing date format
Aug 11th, 2014, 5:10pm
 
Hi.
How can I change the date format (StartDate, EndDate)?

I need »24.04.1564« (dd.mm.yyyy) but always find »24.04.64 22:51« (dd.mm.yy hh:mm).

Thank you.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing date format
Reply #1 - Aug 11th, 2014, 5:33pm
 
If you meant the date format you see in key attribute edit boxes, is the short date format from your OS plus the time. The time element can't be suppressed in key attributes.

In other places dates can be displayed in a different format (e.g. into a string attribute) via Date.format(). To show dd.mm.yyyy use the date format string "D.M0.y", as in $StartDate.format("D.M0.y").

[Admin note - I deleted the duplicate post for you.]
Back to top
 
« Last Edit: Aug 11th, 2014, 5:33pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
luix
Full Member
*
Offline



Posts: 9

Re: Changing date format
Reply #2 - Aug 12th, 2014, 3:48am
 
Hi Mark.
Thank you for your response.

But there are some questions left Smiley

Quote:
In other places dates can be displayed in a different format (e.g. into a string attribute) via Date.format(). To show dd.mm.yyyy use the date format string "D.M0.y", as in $StartDate.format("D.M0.y").


Where shall I change the date format? Didn't find any button, text field or so to enter a »$StartDate.format("D.M0.y")«


That is what TBX shows me, when I enter 23.04.1564 ans 03.05.1616. You see that it adds a day by its own. I enter 23.04. tbx writes 24.04., I enter 03.05. it writes 04.05.



Here it writes a completely new date, which has nothing to do with Shakespeare at all (as far as I know).

Where can I read about the correct date handling or who may explain or show it to me?
I really would like the timeline for some research and documentation work but do not see how.
Thank you
Lutz
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing date format
Reply #3 - Aug 12th, 2014, 6:50am
 
Quote:
Where shall I change the date format? Didn't find any button, text field or so to enter a »$StartDate.format("D.M0.y")«

No, you store the formatted date in a user string attribute and display the latter.

$MyString = $StartDate.format("D.M0.y")

You can then use $MyString elsewhere.

Quote:
You see that it adds a day by its own.

I can replicate this, please report this directly to support. I think the issue is you need to change your OS short date format so it uses 4-digit years and not just the last two, but as I say, ask support directly.

Quote:
Here it writes a completely new date, which has nothing to do with Shakespeare at all (as far as I know).


The event prototype has this $HoverExpression:

if($StartDate){format($StartDate,'l')+if($EndDate){' - '+format($EndDate,'l')}}

See date formats for the explanation of the 'l' format. I suspect you want a different format. Try editing $HoverExpression for the prototype note 'Event' (so it affects all Event-based notes) so it is like this:

if($StartDate){$StartDate.format('D.M0.y')+if($EndDate){' - '+$EndDate.format('D.M0.y')}}

The latter should make the date format look right, assuming the issue with date input can be solved.
Back to top
 
« Last Edit: Aug 12th, 2014, 6:52am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Changing date format
Reply #4 - Aug 12th, 2014, 10:58am
 
Thanks for your queries.  It's remarkable how often people inquire about historical dates in Tinderbox.

First, check your date settings in System Preferences.  OS X short date format is used internally in some parts of Tinderbox, and hence two-digit years, though common in everyday work, are very tricky in actions and rules.  Make sure all your date formats, including short dates, use 4-digit dates.

Second, be wary of date calculations that space the years 1 BC-1 AD. Some Tinderbox calculations fail to account for the absence of a year 0.

Third, beware of subtle issues with calendar changes, especially those relating to the Julian/Gregorian transition.  OS X is quite sophisticated in handling this, but of course it's quite complex, and the Macintosh assumes that the calendar of interest is the one where you're located. This might be wrong, for example, if you're working in Britain but writing about France, or Russia, or Sweden.

I *think* the off-by-one-day issue for historical dates relates to this latter phenomenon.

- - -

In general, if you have a general (or widespread) preference for a particular date format in your work, use System Preferences to adopt it.  If you need a specific unusual format to interface with some other program, or for a particular publications, then the export format commands should accommodate your needs.
Back to top
 
 
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Changing date format
Reply #5 - Aug 12th, 2014, 11:22am
 
When I enter Shakespeare’s birthday in my key attribute field (using American settings and four-digit years) as

    4/23/1564

Tinderbox interprets this as

    4/23/1564 11:14 AM

filling in the time as the current time of day.  I don't observe a change in the date.  

Tinderbox uses the current time if you don't specific a time.  This might be another source of the discrepancy: in many jurisdictions, the convention that midnight starts the day is fairly recent.  Again, I'm not certain how the date routines handle this.

What locale do you use for your system?
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing date format
Reply #6 - Aug 12th, 2014, 1:16pm
 
Interesting. In v6.0.2 on my UK locale 10.8.5 and 10.9.4 systems, I started a new file and added the Event prototype, then added a new note and made it an event. Into $StartDate I typed 23/4/1654 and, on both OSs, I get 24/04/1654 17:57 (time is just local as I didn't provide any).

So in my UK locale a day is being added! By trail and error with other dates I find that:

Input 23/04/1883 sets date 24/04/1883
but:
23/04/1884 sets date 23/04/184 correctly.

Why 1883/84 should be the trigger for this I don't know. Also:

23/04/0102 -> 24/04/0102 (year 102 BCE)
23/04/0012 -> 24/04/0012 (12 BCE)
23/04/0003 -> 25/04/0003 (3 BCE)

The last adds 2 days. Something odd as in UK, we moved to the Gregorian calendar in 1750, not the late 19C.

Factoid: The outrage over the 11 days difference is thought to be behind why these days we start the UK tax year on 6 April rather than 26 March as we had prior to the new-fangled calendar; 25 March was Lady Day, a Quarter Day.
Back to top
 
« Last Edit: Aug 12th, 2014, 1:16pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
luix
Full Member
*
Offline



Posts: 9

Re: Changing date format
Reply #7 - Aug 13th, 2014, 4:05am
 
Hi, Mark and Mark.
I'm writing from Germany on a located system (10.9.4).
The julian/gregorian calendar switch was a 10 days shift somewhere in 1582 (or later). Why should that be responsible for the »day crunch behaviour« of Tinderbox?

Meanwhile I changed Apple's short date to four-digit. Good hint. good for centuries.

Quote:
Input 23/04/1883 sets date 24/04/1883
but:
23/04/1884 sets date 23/04/184 correctly.

Why 1883/84 should be the trigger for this I don't know.


I can reproduce that. 31.12.1883 becomes 1.1.1884 and 1.1.1884 remains 1.1.1884.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Railroads and Tinderbox Six
Reply #8 - Aug 13th, 2014, 2:09pm
 
What’s special about 1883-1884?

It’s when time zones were introduced in the US!  And Tinderbox stores dates in Universal Time but assumes you're entering dates and times in your local time zone.

I'm unclear about how time zone objects behave prior to 1884, but I believe this is responsible for the date conversion anomalies.  Many details of dates are poorly document; I've blogged about some of the perplexities at http://markBernstein.org/ .  FYI
Back to top
 
 
WWW   IP Logged
luix
Full Member
*
Offline



Posts: 9

Re: Changing date format
Reply #9 - Aug 14th, 2014, 5:22am
 
Hi Mark.
I suppose you cannot conjure a solution for the on-day-shift-oddity out of the hat. so I'm fine with correcting dates by hand.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Changing date format
Reply #10 - Aug 14th, 2014, 11:06am
 
The problem with dates before 1883 being sometimes off by one day involves time zone calculations.  

Tinderbox stores dates based on Universal Time, but assumes you're entering dates in the local time of your own time zone. I work in the US, where time zones were introduced in November 1883, and dates before then may suffer the off-by-one issue in conversion. (If you specify a time, there also seems to be a 4-minute correction -- presumably leap minutes.)

Investigation continue; this is far knottier than I would have believed.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing date format
Reply #11 - Aug 14th, 2014, 11:23am
 
Slightly OT but perhaps pertinent to any changes arising is a feature suggestion from some way back relating to being able to set a 'standard' time when making dates via KA-type input. IOW, if no time is given at input then a time (set in Doc Settings?) is used instead; perhaps it might need to be linked to specified prototype(s) or descendants of certain containers. For docs recording mainly historical events it might be useful if they all used a given time. If nothing else it would make any date maths errors mostly go the same way.

Mentioning the latter isn't an urgent request but more something to bear in mind if the date handling code is going through some triage so such a feature isn't harder to implement in the future.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print