BIRT Using Date parameter in script - javascript

I am using BIRT and am trying to modify the text on a chart based on an end date report parameter, which I've assigned a default value and of course, Date datatype. SQL queries also use this parameter. To test passing of value, I write the below script.
function beforeDrawLegendItem( lerh, bounds, icsc )
{
var endDate = new Date(params["rptEndDate"].value);
}
However, when I try to preview the chart, it is blank, indicating that there is something wrong with my script. When I comment out the var endDate line, it renders as normal. I've tried other ways to get the value like:
var endDate = new Date();
Which works, but when I try to assign the parameter value:
endDate = params["rptEndDate"].value;
It fails again. Removing the .value part also fails. Also fails when I try to use reportContext to get the parameter value. According to other sources my script should be correct. Is there anything I am missing?

This is due to the specifity of the chart engine: "params" object is not made available in chart scripts, use "getParameterValue" instead. It will work like this:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
var endDate = new Date(getParameterValue("rptEndDate"));
}

The Previewer tends to offer less then optimally formated or fully functional design. Open the report in the format/tool that will be used in the final delivery for true testing durring design. Personally I have Apache on my test server and do all of my preview testing as a web page.

Related

I override api_date of themplates in DHTMLX but it is not used?

In dhtmlx gantt, you can format input date (from string or any type) into javascript date. This date is used to draw chart. Base on the dhtmlx document, you can replace converter (api_date) by custom function:
I override the function as follow:
gantt.templates.api_date = function(date){
throw "It is called";
};
but, it never is called.
api_date template and config are no longer used. We will update the information in the documentation. Please use xml_date as hadi.mansouri suggested.
I don`t know why this function is not called. I also confuse for this, because official documents of DHMTLX Gantt (as you mentioned, api_date) say it should works.
However I found that if you override xml_date it will work as you want. Although it is named xml_date but it works for json data also.
So could use following snippet:
gantt.templates.xml_date = function(date){
// Your customized code.
// return a Date object.
};

How to detect changes with Date objects in Angular2?

Date objects that are modified using setDate method arent getting updated in template.
In template:
<p>{{date | date:'mediumDate'}}</p>
In component:
nextDay(){
this.date.setDate(this.date.getDate()+1);
}
But when I call nextDay function, the template isnt updated with the new value.
The only way I could get the change detection working was doing this:
nextDay(){
var tomorrow = new Date();
tomorrow.setDate(this.date.getDate()+1);
this.date = tomorrow;
}
Are there a better way to accomplish this same task?
I think that is the right way, to change the reference of the date variable. From the docs here we have:
The default change detection algorithm looks for differences by comparing bound-property values by reference across change detection runs.
So if the date reference remains the same, nothing will happen. You need a new Date reference and that's why the second version of nextDay() works.
If you remove the formatting pipe you will see that still only the second version of nextDay() works.

Dates - JavaScript and C#

I hate dates, I can never get them to behave.
I have a javascript variable that looks like this:
var currentDate = new Date();
I pass this to a C# Web API controller as a parameter.
My local time was 12:43 but when I put a breakpoint in my action it shows 11:43. The problem is, that if I do this at 00:43 then my controller would take the date as yesterday. I need it to pick out the right day. If I select the currentDate as 02/09/2015 12:43 then I need my controller to use the same date.
I know this has something to do with local times etc, but how can I get them all to use the same one?
Any help would be greatly appreciated.

Auto calculate todays date when doc opens and add days to date in another field

I am using Adobe XI Standard and have a pdf document with a text field “Today” with a Mouse Up Java script of
var f = this.getField("Today");
f.value = util.printd("mmm/d/yyyy", new Date());
Problem 1) I want this to automatically update when the document opens instead of when the mouse enters it but I dont know how or where to place the script in the proper place.
I have a text field labeled “text11” formatted to be a date mm/dd/yyyy
I have another text field labeled “21stDay” which I want to calculate 21 days from the date in the “text11” field.
Problem 2) I have not been able to get any script to work. Can anyone please tell me how to make this work properly and where to exactly place the scripts as I am just a novice at doing this.
Thank you in advance!
I believe that there are two potential ways to do this:
An OpenAction entry in the Catalog root with an Action dictionary of S(ub)type JavaScript
Named JavaScripts seem to be executed when the document is first opened in Acrobat.
For the fomer see table 3.25 in section 3.6.1 and section 8.5 in the PDF v1.7 Reference, and section 3.6.3 for the latter.
The first thing you can do with a Document-level script containing just that single line:
this.getField("Today").value = util.printd("mmm/d/yyyy", new Date()) ;
If you encounter timing issues (meaning that the field does not get filled reliably, use the PageOpen event of the page on which the document opens. This makes sure that the script is run only when the document is properly loaded.
For the second question, this should work (not I have not verified the code):
var now = new Date() ;
var then = new Date() ;
then.setDate(now.getDate+21) ;
this.getField("text11").value = util.printd("mm/dd/yyyy", then) ;
Note that the Date object is smart enough to properly convert a date number greater than the date of the end of month.

Save the actual date in a variable (only date, no time)

I want to save the actual date in a variable. only the date, no time
var a = #Date(#Now());
datasource.replaceItemValue("variable", a)`
And
var a = #Date(#Now());
var b = new Date(a.getYear(), a.getMonth(), a.getDay());
datasource.replaceItemValue("variable", b)
Are returning 28.10.14 00:00
var dt:NotesDateTime = #Date(#Now());
datasource.replaceItemValue("variable", dt.getDateOnly());
Is throwing me an error
Isn't there a simple way to get only the actual date without the time?
Use setAnyTime() metohd of NotesDateTime class to remove time component.
If you want to save only the date use a textfield and convert the text to date, if you need it in your code
#Now uses a java.util.Date, which includes time portions. .getDateOnly() is probably throwing an error because that returns a String.
The underlying session.createDateTime() method accepts either text, a java.util.Date or a java.util.Calendar. I think all of them need to include a time element.
If you're only storing the value for reference, I'd agree with brso05 to not worry.
If you're ever likely to use #Adjust (or an equivalent), then not worrying about the time is a recipe for disaster, because every time you try to adjust, you need to remember to take into account Daylight Savings Time.
One option is to set the time to 12:00 midday. That means DST will not be a problem.
java.sql.Date is specifically designed to only include the Date portion, without a time element. Jesse Gallagher talks about java.sql.Date in the context of his frostillic.us framework https://frostillic.us/f.nsf/posts/32A63DD640D868D885257D18006659A9 and he was the one I found out about java.sql.Date from. I'm not sure how he stores those values though.
I'm not sure if the OpenNTF Domino API will allow you to just pass a java.sql.Date to a field and so store just the date portion.

Categories

Resources