date comparison (or comparison between 2 numbers)

var futureDate = 201505250000000;
var now = Time.now();
var info = Calendar.info(now, Time.FORMAT_SHORT);
var dateStr = Lang.format("$1$$2$$3$$4$$5$$6$", [info.year.format("%04d"), info.month.format("%02d"), info.day.format("%02d"), info.hour.format("%02d"), info.min.format("%02d"), info.sec.format("%02d")]);



I'm trying to compare the current date (dateStr) vs the futureDate. Does not work.

Sys.println("Datestr " + dateStr);
var kkk = dateStr.toNumber();
Sys.println("datestr.toNumber " + kkk);


Output becomes:
Datestr 20150522114800
datestr.toNumber -1464438032


if I try to just do
if ( dateStr.toNumber() > futureDate ) {


I get an error as well.


why can't I compare the 2 dates?
  • Isn't it inappropriate to try to just push your idea on others? ;) I'm pretty sure you have made comment simply because someone did not place their code in a code block when posting on the forum.


    I do agree that i++ seems more logical. (only that we've been wired / taught that way).
    well.. i dont get and still done get the i =+ 1

    that is just not logical for me as well as while it may look neater - it does take some use to to actually read the code.
  • I'm pretty sure you have made comment simply because someone did not place their code in a code block when posting on the forum.


    I think you're comparing apples and oranges here, but yes, I tell people that using [/i] tags will result in properly formatted code in their posts. I suggest that they make the change and describe what tangible benefit we will observe if they are to make the change.

    Upon re-reading your post, you did provide a rationale as to why the change should be made (code readability), so your point is pretty close (readability vs a tiny change). Unfortunately I think we'll disagree about the cost of making the suggested changes.
  • I do agree that i++ seems more logical. (only that we've been wired / taught that way).
    well.. i dont get and still done get the i =+ 1

    that is just not logical for me as well as while it may look neater - it does take some use to to actually read the code.


    I'm pretty sure you mean i += 1 which is just shorthand for i = i + 1.

    Perhaps I have an advantage. I started coding in C years ago, so in my mind ++j has a very specific meaning (increment first, then return j) when compared to j++ (return j and then increment it).
  • I'm pretty sure you mean i += 1 which is just shorthand for i = i + 1.


    See what I mean. Can't even remember how to write that properly. :-(
  • Former Member
    Former Member over 10 years ago
    ....I think we'll disagree about the cost of making the suggested changes.
    You've lost me on the cost bit.

    Actually this has got me to thinking, and I have to conclude that I'm going to convert.

    Without putting thought into it, I simply read the precedence in it's formatted order on the page, and my reasoning was based on a substitute case. When I did finally apply the grey matter, I remembered that the 3rd statement is an after condition, so you do want to increment j before it is used next.

    Were you to apply ++j to a variable after the for loop, eg nextVar = ++j;, you would see the correct result. Whereas if you were to apply j++ to a variable after the for loop, you would get a double-up of the last value. If the loop had not run then it wouldn't get called, so the next variable would still get the correct value.

    Obviously you don't need convincing, voicing my reasoning for others.