Compare date ranges with API


#1

Does anyone know of an API that can compare date ranges? My use is pretty simple. I want users to enter the expiration date of their license and I want that date compared to the current date. If it’s over 6 months, I want them directed one way, and if it’s under 6 months, I want them directed to a different gambit. Really, I would just need a return of 1 or 0. Maybe this is possible with Math.js and some JSON that pulls current date? Sounds more complicated through Math.js than I am comfortable with. Thoughts?


#2

I looked around, but couldn’t find anything useful.
We will evetually have a feature to do these kinds of comparison within the Conditional Jump feature.

For now, there is a hacky way to do this in the Builder if you are upto it. Use this as a condition in a Conditional Jump branch:

{{=new Date(this.ursp.license_expiration_date).getTime()}}
Less Than
{{=new Date(Date.now() - 15552000000).getTime()}}

Where license_expiration_date is the gambit name on which you are collecting the Expiration date using the Date Scroller InputUI.
15552000000 is just the number of milli seconds in 6 months, which i subtracted from the current date to get the unix epoch timestamp, 6 months in the past.

I made this here to test it out:
https://memegen.hellotars.com/conv/r1d0p0/?_startgid=21

===========================
Check this screenshot of the gambit config for reference, to see how different dates can be used:


Super large bots as landing pages?
#3

Cool! Thanks! This will work.