Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    13.0d_2021-07-16 Regression in Timeline day view

    Hi,
    After SGWT LGPL upgrade from v13.0d_2021-04-05 to v13.0d_2021-07-16 I have got this exception:
    Code:
    Uncaught TypeError: format.replace is not a function
    in CalendarView.js getInnerFieldTitle() function:
    Code:
        getInnerFieldTitle : function (headerLevel, spanIndex, startDate, endDate) {
            var granularity = headerLevel.unit,
                result = headerLevel.titles ? headerLevel.titles[spanIndex] : null
            ;
            if (!result) {
                // only generate a default value and call the titleFormatter if there was no
                // entry for this particular span in headerLevels.titles
                if (granularity == "year") {
                    result = startDate.getFullYear();
                } else if (granularity == "month") {
                    result = startDate.getShortMonthName();
                } else if (granularity == "week") {
                    // use the week number for the Date.firstWeekIncludesDay'th day of the week - thursday
                    var midWeek = isc.DateUtil.getStartOf(startDate, "W", null, this.calendar.firstDayOfWeek);
                    midWeek.setDate(midWeek.getDate() + (midWeek.firstWeekIncludesDay - this.calendar.firstDayOfWeek));
                    result = this.calendar.weekPrefix + " " + midWeek.getWeek(this.calendar.firstDayOfWeek);
                } else if (granularity == "day") {
                    // get the order of date parts from the inputFormat and use the defaultDateSeparator
                    var format = isc.Date.getInputFormat();
                    // remove year and transform day
                    format = format.replace("Y", ""); //<--Uncaught TypeError: format.replace is not a function
                    format = format.replace("D", "d");
                    format = format[0] + isc.Date.getDefaultDateSeparator() + format[1];
                    result = isc.DateUtil.format(startDate, format);
                } else {
                    var mins = startDate.getMinutes().toString();
                    if (mins.length == 1) mins = "0" + mins;
                    result = startDate.getHours() + ":" + mins;   
                }
                if (isc.isA.Function(headerLevel.titleFormatter)) {
                    result = headerLevel.titleFormatter(headerLevel, startDate, endDate, result, this.calendar);
                }
            }
    
            return result;
        },
    format variable value in my case is:
    Code:
    (anonymous)
    DateUtil.java:1495
    ƒ anonymous(dateStr_0_g$)
    Here is diff comparing to working (2021-04-05) version.
    Code:
                     result = startDate.getShortMonthName();
                 } else if (granularity == "week") {
                     // use the week number for the Date.firstWeekIncludesDay'th day of the week - thursday
    -                var midWeek = isc.DateUtil.getStartOf(startDate.duplicate(), "W", null, this.calendar.firstDayOfWeek);
    +                var midWeek = isc.DateUtil.getStartOf(startDate, "W", null, this.calendar.firstDayOfWeek);
                     midWeek.setDate(midWeek.getDate() + (midWeek.firstWeekIncludesDay - this.calendar.firstDayOfWeek));
                     result = this.calendar.weekPrefix + " " + midWeek.getWeek(this.calendar.firstDayOfWeek);
                 } else if (granularity == "day") {
    -                result = (startDate.getMonth() + 1) + "/" + startDate.getDate();
    +                // get the order of date parts from the inputFormat and use the defaultDateSeparator
    +                var format = isc.Date.getInputFormat();
    +                // remove year and transform day
    +                format = format.replace("Y", "");
    +                format = format.replace("D", "d");
    +                format = format[0] + isc.Date.getDefaultDateSeparator() + format[1];
    +                result = isc.DateUtil.format(startDate, format);
                 } else {
                     var mins = startDate.getMinutes().toString();
                     if (mins.length == 1) mins = "0" + mins;
    Could you have a look?
    MichalG

    #2
    Can you confirm whether you're loading a locale and/or setting global date formats/setDateParser()?

    Comment


      #3
      Yes, we are using pl _PL locale and setting global date parser like this:
      Code:
          private static void setSystemWideDateTimeParser() {
              DateUtil.setDateParser(new DateParser() {
      
                  public Date parse(String dateString) {
                      Date date = null;
                      if (dateString == null) return null;
                      DateTimeFormat dateFormatter = dateTimeFormat;
                      try {
                          date = dateFormatter.parse(dateString);
                      } catch (Exception eDatetime) {
                          dateFormatter = dateFormat;
                          try {
                              date = dateFormatter.parse(dateString);
                          } catch (Exception eDate) {
                              SC.logWarn("Parsing date & time format: "+eDate.toString());
                          }
                      }
                      return date;
                  }
              });
          }
      MichalG

      Comment


        #4
        You should find this working as you expect in today's builds, dated July 20 or later.

        Comment


          #5
          Yes, fixed for me in v13.0d_2021-07-20.
          Thank you very much.
          MichalG

          Comment

          Working...
          X