Justinmind-logo
 

Setting dates relative to other dates

prototype user shared this question 4 years ago
Answered

I need to be able to dynamically set dates. For example, one day prior to the system date or one day after the date displayed in another date widget. It is too cumbersome to try to parse out the slashes and manually replace the date especially since each month has a different number of days.

Replies (5)

photo
1

Dear Rechell,


I've just realised that by oversight we didn't reply this post. Can you elaborate more on what you mean? Are you using the date widget?


Best,


Sonia Durán

photo
1

I mean doing "date arithmetic". For example set the value of a date box to one day after today's date.

photo
2

Hi Rechell,

I know you would prefer the ability to do date arithmetic to be built into JIM, but in the event that it is not and it is critical that you are able to do it, you can accomplish it using the expressions I've built in the attached prototype (see screenshots below). Download the file and change the extension from .rar to .vp. It is not compressed.

I'll warn you, the expressions to achieve what you are hoping to do are pretty elaborate, but I believe them to be accurate. They are based upon formulas using Julian Day Count integers, described here:

https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html

Should you decide to dig into it, I've tried to mimic the formulas (variables, etc.) as they appear on the linked site to make them easier to follow/decipher.

Note to Justinmind developers: If these formulas were converted into functions (eg. JDC() for Julian Day Count and GCD() for Gregorian Calendar Date), date arithmetic would be possible. Also, as you can see by the expressions, it would be huge step forward in simplifying them if a truncate function was available. The work around makes the expressions a great deal larger.

Cheers!!

030bda53b43810a39513ae3de531c2b2 fe1d7cc5fbb9d9247f4f2140b1d96daa

45d014a4d5852f78a52e849e5fcccb18 . e5553b0fa9ed837614321ebde1fdd4b6

P. S. The file I originally attached was the wrong one. I noticed it shortly after (20 minutes or so) and replaced it with the correct file. As long as you have the file "date_calculations_prototype.rar", you have the correct one. ("date_difference_calculation_prototype.rar" is the incorrect one)

photo
1

Hi Friend


I am new to this. I downloaded your file and it contains some xml file. How to open this file.

photo
1

You need to decompress the file. This article can help.

photo
1

Hi eggroll,


I'm new to justinmind. I understand the variable usage in your example. But it seems that i can not locate te calculations in the example. Although everythings is working.

Can you pinpoint the location of the used formulas?


Kind regards,

Harm

photo
1

Hi,


It’s been awhile since I’ve used JIM and I don’t have access to the prototype at the moment, but look up “expression builder” in both the documentation and the community Q&A. I believe expressions (i.e. formulas built in the JIM expression builder) are attached to events and, if I had to guess, the events these expressions are attached to in my prototype are button pushes, the buttons being those in the UI that trigger the date calculations.


Once you locate the expressions, though, just know that they will be very long and a bit convoluted out of neccessity due to some built-in functions (e.g. truncation) not available in JIM at the time. And I don’t know for sure that my built expressions are as optimal or efficient as possible. So, deciphering them may require using the website link in my original response for the mathematical formulas (if the link is still live), other sources for things such as how to perform truncation without a built-in truncation function, etc., and paper and pencil to work out how I translated the mathematical formulas (formulae? 😀) to JIM expressions. I do remember that I had to be very precise in ordering the different parts of the expression within the expression builder in order to achieve the correct output.


Hope this helps. Post back with your progress.


Cheers!

photo
1

Hello Eggroll,


Thanks for the reply. I found the functionality. And to be onnest also a bit a shamed.

Turns out I only had to increase the Events window in order to see all created events in de example. ;(

Kind regards,

Harm

photo
photo
1

Hi there,


Thank you so much for your contribution @eggroll! :) I hope this helps @RechellSchwartz.


Best,


Sonia Durán

photo
2

Thank you, @egroll. What you did is very impressive. However, I do feel date arithmetic is standard functionality that should be incorporated into Justinmind. Any chance of seeing this in a future release?

photo
1

Unfortunately no plans at the moment.


Best,

photo
1

Any chance of getting a truncate function any time soon?

photo
1

You could do that with the Round function "trunc(x)=round(x-0.5,0)" however, would only work with positive numbers. Anyway, I will transfer your suggestion to our development team.

Best,

photo
Leave a Comment
 
Attach a file