Project: Birt
Bug 224256 BIRT: Expr. builder needs easy way to specify a date constant
Reported: 2008-03-26 19:49:18 | Status: verified fixed

I'm creating a report in which I want to use a filter that finds all dates before Jan-1-2006. Using the expression builder, I hunted around but could find no date constant feature. The best I could find was Date.parse( ), but it is not clear what format this function takes. Checking a JavaScript reference, it has this to say about Date.parse: "The ECMAScript standard does not specify the format of the strings that can be parsed...it is not in general possible to write dates in a way that is guaranteed to be understood by all JavaScript implementations." Hence, it is unclear what format to use in the string. I will end up experimenting with Rhino to figure it out. Doing so suggests that Date.parse takes a locale-specific date. For example "1/2/2005" appeared to give Jan. 2, 2005. The problem is that this probably won't work when run in any other locale. How would I create a locale-independent date? Again, looking in the JavaScript reference reveals that the Date constructor does the trick: new Date( year, month, date, ... However, the constructor (along with argument hints) does not appear in the expression builder, making it necessary to open a book to figure out what to do for this very typical task. Better would be to provide a BIRT-specific function to do the job. Perhaps: dateConst( year, month, day [, hour, min, sec] ) The arguments would make it very clear where to put each date bit. Internally this could simply call the date constructor. Or, add the date constructor to the expression builder somehow. Maybe add a "constant" section with entries for string, dates, JavaScript-defined constants, BIRT-defined constants, etc. In any event, make it much easier to figure out, using nothing but the expression builder, how to define a date constant.

Files changed in fix:
UI/org.eclipse.birt.report.designer.core/src/org/eclipse/birt/report/designer/util/AlphabeticallyComparator.java UI/org.eclipse.birt.report.designer.core/src/org/eclipse/birt/report/designer/util/DEUtil.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/ui/IReportGraphicConstants.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/ui/ReportPlatformUIImages.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/ui/dialogs/ExpressionBuilder.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/ui/dialogs/ExpressionProvider.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/ui/expressions/ISortableExpressionProvider.java