Wednesday, August 1, 2012

Javascript to C# Converter Online

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. var dob = $('.txtBabyBirthDate').val().split("/");
    var fromdate = new Date(dob[2], dob[1] - 1, dob[0]);
    var todate1Sep = new Date("2019-09-01");

    age = [],
    y = [todate1Sep.getFullYear(), fromdate.getFullYear()],
    ydiff = y[0] - y[1],
    m = [todate1Sep.getMonth(), fromdate.getMonth()],
    mdiff = m[0] - m[1],
    d = [todate1Sep.getDate(), fromdate.getDate()],
    ddiff = d[0] - d[1];

    if (mdiff < 0 || (mdiff === 0 && ddiff < 0))--ydiff;
    if (mdiff < 0) mdiff += 12;
    if (ddiff < 0) {
    fromdate.setMonth(m[1] + 1, 0);
    ddiff = fromdate.getDate() - d[1] + d[0];
    --mdiff;
    }

    //השמת ערך בשדה נסתר גיל --ההשמה לתוך מערך גיל

    if (ydiff > 0) age.push(' שנים:: ' + ydiff);//+ (ydiff > 1 ? 's ' : ' ')
    if (mdiff > 0) age.push(' חודשים:: ' + mdiff);//+ (mdiff > 1 ? 's' : '')
    if (ddiff > 0) age.push(' ימים:: ' + ddiff);//+ (ydiff > 1 ? 's ' : ' ')


    $(".BabyAge1SepValue").val(age.join(''));

    ReplyDelete