INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Maths and Dates - What breaks this?  (Read 544 times)

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Maths and Dates - What breaks this?
« on: July 14, 2019, 04:41:55 am »

In this thread, I worked out a system to have MC calculate a person's age from the date of a photo. It's an excellent solution that I now use to return ages for all immediate family members.

Auto import applies all the birth dates to every photo it imports.
The "Age" field then checks to see if any family members have been tagged, and if so, continues to calculate their age at the time the photo was taken, and finally, applies formatting based on the returned result, and outputs a neat age string.

The whole thing relies on the following bit of code:

formatdate(math(now()-([date,0]-[age-amiee-birthday,0])),elapsed)

More granular formatting is applied depending on the result of this expression.

The question is....
Why, when the expected formatted result would be 68 years or higher, it breaks.

Example:
Photo taken 8th June 2019 at 12:07:34
Birth Date: 13th April 1951 at 01:01:00
The maths above returns a value of: 18766.975463
Which MC's "formatdate(Elapsed)" outputs as "--35791394:4294967288"

The expected output should be 68 years.

Any ideas?

DJLegba

  • Citizen of the Universe
  • *****
  • Posts: 995
Re: Maths and Dates - What breaks this?
« Reply #1 on: July 14, 2019, 05:46:01 am »

Google POSIX time. 68 years is the biggest number that can be represented with a 32-bit integer under POSIX time.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Maths and Dates - What breaks this?
« Reply #2 on: July 14, 2019, 06:21:12 am »

Well, that's disappointing; and interesting... being reported as the next "Y2K" scare...

https://en.wikipedia.org/wiki/Year_2038_problem

This needs to be sorted, now. My MC is broken being unable to calculate my mother's age in her photos. Unacceptable :D

Thanks for the reply, I would never have known to google that without your prompt. I'll see if I can shoehorn a workaround in there for this.

You think this "Y2038" thing is more of a real worry than "Y2K" was?

-marko

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42346
  • Shoes gone again!
Re: Maths and Dates - What breaks this?
« Reply #3 on: July 14, 2019, 12:11:16 pm »

I'll try to repro this in the the debugger tomorrow and see if there's anything we can do.  Thanks.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42346
  • Shoes gone again!
Re: Maths and Dates - What breaks this?
« Reply #4 on: July 15, 2019, 07:55:48 am »

This will be fixed next build.

Our format duration function call took an int64 but we were casting it as an int for the call in question.

Thanks for the help.
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Maths and Dates - What breaks this?
« Reply #5 on: July 15, 2019, 12:02:02 pm »

Stunning.

After reading up on this, a bit, and grasping only the very basics, I had kind of resigned myself to this being one of those 'just the way it is' things.

My 'thank you' keys are getting a good work-out this evening :)

-marko

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42346
  • Shoes gone again!
Re: Maths and Dates - What breaks this?
« Reply #6 on: July 15, 2019, 12:03:43 pm »

There are some advantages to all the date / time code being written by us from the ground up :)  It means we're not vulnerable to some of the bugs others might be.
Logged
Matt Ashland, JRiver Media Center
Pages: [1]   Go Up