Problem with dateItems and math?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Problem with dateItems and math?

Post by bogs » Sun Sep 29, 2019 10:54 pm

I've started a bit more indepth lesson about dateItems to go with the other tutorials I've put up, and ran across something I *think* is a bug.

If you add (or subtract) a number from an item of the dateItems, your supposed to get returned the increased item and all the other items increased as well.

That is probably poorly worded. If needed, I can try to explain it better :?

Anyway, I whipped up this little time machine demo.
dateItems1.png
This shows the addition of years as I expect it too...
The above picture shows what I expect to happen...
dateItems2.png
This shows...what the heck?
This is what happens after going large (and not all that large either!) I notice that it is the dateItems, and the items themselves are correct, but why is it showing the items instead of the formatted output as in the picture at the top?

The routine is simple enough...

Code: Select all

on mouseUp
   put field 3 into tmpItems
   put the hilitedButtonName of group 1 into tmpName
   put the number of button tmpName into tmpNum
   
   add field "addNum" to item tmpNum of tmpItems
   convert tmpItems from dateItems to long date and long time
   
   put tmpItems into field 4
   set the itemDelimiter to space
   put item 5 to 6 of field 4 into field 5
   
   delete item 5 to 6 of field 4
end mouseUp
And here is the stack -
timeMachine.livecode.zip
The stack...
(1.5 KiB) Downloaded 135 times
Reproducible in 6.5 to 9.5.
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Problem with dateItems and math?

Post by Klaus » Sun Sep 29, 2019 11:38 pm

Works as advertized here, macOS 10.14.6, LC 9.5!

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Problem with dateItems and math?

Post by SparkOut » Mon Sep 30, 2019 6:33 am

https://quality.livecode.com/show_bug.cgi?id=4941 says dates currently work between 1970 and 3000 cross platform. Mac users have a wider range of usable dates but not strictly supported.
It looks like your time machine isn't seeing the year 2519 as a date any more, so treats the dateItems values as one literal string, therefore not able to do any conversion.
So I would imagine this is a bug, if it's not even possible to use the expected date range that's supposed to be supported. But I don't know for sure, although in any event, such a fundamental function should work cross platform on a much wider range of arbitrary dates.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Problem with dateItems and math?

Post by bogs » Mon Sep 30, 2019 9:09 am

Klaus wrote:
Sun Sep 29, 2019 11:38 pm
Works as advertized here, macOS 10.14.6, LC 9.5!
I'm curious Klaus, how high a number did you test with? Here on 'nix, the number of years you could advance was embarassingly low, 18 years worked, 19 did not :oops:
dateItems3.png
17...18...19 <snap>....
@SparkOut -
Thanks for the find, I somehow must have missed it when I went looking. I'll add the stack and results from my testing there.

*Edit - the bug report marked a duplicate was interesting reading as well.
Mark Waddingham 2014-04-11 17:24:19 EDT wrote:
This isn't a bug exactly. The century cutoff means that 1/1/72 is interpreted as 1/1/2072 which is outside the date range that the linux engine can currently handle.

Therefore, this is a duplicate of bug 4941.

*** This bug has been marked as a duplicate of bug 4941 ***
I'm guessing that means that something broke more between 2007 and 2014 on 'nix. In '07 at least we could get to the year 3000, now apparently can't even get past my expected lifetime :shock:
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Problem with dateItems and math?

Post by Klaus » Mon Sep 30, 2019 2:52 pm

I tesetd until 50,000 years and got: Sunday, September 29, 52019
It is a Mac thing, I think...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Problem with dateItems and math?

Post by dunbarx » Mon Sep 30, 2019 3:01 pm

Klaus.

You know that in 50,000 years you will have over 41,000,000 posts.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Problem with dateItems and math?

Post by bogs » Mon Sep 30, 2019 3:04 pm

Klaus wrote:
Mon Sep 30, 2019 2:52 pm
I tesetd until 50,000 years and got: Sunday, September 29, 52019
That figures, I'd have settled for a lousy millennia :P
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”