Hi,
i'm facing a bug with isc.DateUtil.getStartOf (despite is not documented is used in some example) which seems to not return the correct StartOf a week.
In this case i'm working with 13/09/2015 (Sunday) and first day of week on monday. The function return 14/09/2015 instead of 07/09/2015 which is pretty wrong.
1. ISC_VERSION:
6. Code snippet to be used HERE or in any example page
By further inspection in debug-modules i noticed that there seems to be a missing control on "delta" compared to the isc.DateUtil.getEndOf function.
i'm facing a bug with isc.DateUtil.getStartOf (despite is not documented is used in some example) which seems to not return the correct StartOf a week.
In this case i'm working with 13/09/2015 (Sunday) and first day of week on monday. The function return 14/09/2015 instead of 07/09/2015 which is pretty wrong.
1. ISC_VERSION:
- SNAPSHOT_v10.1d_2015-09-15/EVAL Development Only
- v10.0p_2015-09-15/Enterprise Development Only
6. Code snippet to be used HERE or in any example page
Code:
var endOfWeekDate = new Date(1442144591000); isc.VStack.create({members:[ isc.Label.create({ height: 30, padding: 10, align: "center", valign: "center", wrap: false, showEdges: true, contents: "<b>MY DATE: </b>"+isc.DateUtil.format(endOfWeekDate,"dd/MM/yyyy") }), isc.Label.create({ height: 30, padding: 10, align: "center", valign: "center", wrap: false, icon: "icons/16/approved.png", showEdges: true, contents: "<b>Week Start(first day is sunday): </b>"+isc.DateUtil.format(isc.DateUtil.getStartOf(endOfWeekDate,"W"),"dd/MM/yyyy") }), isc.Label.create({ height: 30, padding: 10, align: "center", valign: "center", wrap: false, icon: "icons/16/approved.png", showEdges: true, contents: "<b>Week End(first day is sunday): </b>"+isc.DateUtil.format(isc.DateUtil.getEndOf(endOfWeekDate,"W"),"dd/MM/yyyy") }), isc.Label.create({ height: 30, padding: 10, align: "center", valign: "center", wrap: false, icon: "icons/16/close.png", showEdges: true, contents: "<b>Week Start(first day is monday): </b>"+isc.DateUtil.format(isc.DateUtil.getStartOf(endOfWeekDate,"W",null,1),"dd/MM/yyyy")+ "</br><strong>This should be 07/09/2015</strong>" }), isc.Label.create({ height: 30, padding: 10, align: "center", valign: "center", wrap: false, icon: "icons/16/approved.png", showEdges: true, contents: "<b>Week End(first day is monday): </b>"+isc.DateUtil.format(isc.DateUtil.getEndOf(endOfWeekDate,"W",null,1),"dd/MM/yyyy") }) ]});
By further inspection in debug-modules i noticed that there seems to be a missing control on "delta" compared to the isc.DateUtil.getEndOf function.
- isc.DateUtil.getStartOf relevant code portion
Code:var newDate; if (logicalDate) { newDate = Date.createLogicalDate(year, month, dateVal); } else { newDate = Date.createDatetime(year, month, dateVal, 0, 0, 0, 0); } var delta = firstDayOfWeek - dayOfWeek; newDate.setDate(newDate.getDate()+delta); return newDate; [B][/B]
- isc.DateUtil.getEndOf relevant code portion
Code:case "w": // end of week var delta = (6-(dayOfWeek-firstDayOfWeek)); if (delta >= 7) delta -= 7; var endDate = dateVal + delta; if (logicalDate) { return Date.createLogicalDate(year, month, endDate); } else { return Date.createDatetime(year, month, endDate, 23, 59, 59, 999); } [B][/B]
Comment