timeHelper.getTimeAsDateTime bug for February/March

Posted by: metrik on 11 April 2022, 12:59 am EST

  • Posted 11 April 2022, 12:59 am EST

    Hello,

    I have noticed that there seems to be a bug in timeHelper.getTimeAsDateTime function. I was trying to understand why my Wijmo chart didn't show X axis labels for dates from March 29th to March 31st.
    And this is what I've found during my research of minified code:

    _timeHelper.prototype.getTimeAsDateTime = function () {
    if (this.hour >= 24) {
    this.hour -= 24;
    this.day += 1
    }
    if (this.month < 0) {
    -1 - this.day;
    this.month = 1
    } else if (this.month > 11) {
    this.month - 12;
    this.month = 12
    }
    if (this.day < 1) {
    -1 - this.day;
    this.day = 1
    } else if (this.day > 28 && 2 == this.month) {
    this.day - 28;
    this.day = 28
    } else if (this.day > 30 && (4 == this.month || 4 == this.month || 6 == this.month || 9 == this.month || 11 == this.month)) {
    this.day - 30;
    this.day = 30
    } else if (this.day > 31) {
    this.day - 31;
    this.day = 31
    }
    if (this.second > 59) {
    this.second - 59;
    this.second = 59
    }
    if (this.minute > 59) {
    this.minute - 59;
    this.minute = 59
    }
    return new Date(this.year, this.month, this.day, this.hour, this.minute, this.second)
    };


    Seems like this function is trying to correct possibly invalid "day" values and for February it only allows maximum "day" value of 28.
    There are two problems with this:

    1. month is being compared to number "2" which is wrong. Month values are zero-based, so 2 means March (and March has 31 days). Correctly, it should have compared to 1, like this:

    else if (this.day > 28 && 1 == this.month) { // <-------- this is February (number 1)
    this.day - 28;
    this.day = 28
    }


    2. Seems like the comparison doesn't really care about ordinary non-leap years. For February only once in 4 years there exists day number 28 (day numbers are also zero-based). For the rest of the years it should have compared to 27.


    Could you please check the code and assist? Is this really a bug or am I wrong somewhere?
    Thank you!
  • Replied 11 April 2022, 8:49 pm EST

    Hi,

    Thanks for reporting this issue. I could see the errors in the code but I was not able to replicate the labels issue. Can you please refer to the sample link below and modify this accordingly so that march labels are not displayed (also check that the version of the sample and your version is same), so that I can investigate further:

    https://stackblitz.com/edit/js-mzmhxg

    Regards,
    Ashwin
  • Replied 11 April 2022, 9:39 pm EST

    Hi Ashwin,

    I have modified your example to reproduce the problem: https://stackblitz.com/edit/js-pbatce

    As you can see, the chart now shows data by hours during one single day. If the day is chosen as March 29th - March 31st, labels in X axis are missing.
    If you change the day to e.g. March 28th, labels are shown normally.

  • Replied 13 April 2022, 4:49 pm EST

    Hello,

    The issue does seem like a bug therefore we have reported the issue to our Dev team for further investigation of the issue with an internal tracking ID WJM-22892. We will provide you with a response on this as soon as we get any updates.

    Sorry for the inconvenience.

    Regards
  • Replied 21 April 2022, 12:19 am EST

    Hello Sonu,

    have you got any update from the development team on this please?
    Also, maybe the development team could advise some workaround, so that we didn't have to wait for a proper fix? This issue is blocking us from resolving our customers bug report.
  • Marked as Answer

    Replied 21 April 2022, 3:21 pm EST

    Hello,

    The issue has been fixed in the latest nightly build 5.20221.842-nightly.d20220422.t020129
    and will be available in the next release build. You can verify the behavior from the sample link given below:

    https://stackblitz.com/edit/js-bbms62?file=index.js

    Thank you for your patience.

    Regards
  • Replied 21 April 2022, 6:12 pm EST

    Thanks Sonu, looking forward to the new release.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels