Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » javascript: toLocaleDateString and BIRT datetime functions
javascript: toLocaleDateString and BIRT datetime functions [message #500154] Wed, 25 November 2009 08:39 Go to next message
Rafal is currently offline RafalFriend
Messages: 33
Registered: July 2009
Member
Hi,
In my dynamic text field I have a script:

BirtDateTime.addDay(new Date(),-1).toLocaleDateString();

which doesn't work because of an error:

TypeError: Cannot find function toLocaleDateString in object Tue Nov 24
09:36:01 CET 2009. (<inline>#1)

It seems like addDay method doesn't really return javascript DateTime
object. Do you know how to solve this problem, or maybe have another
easy way to show yesterday's date in my locale?

Thanks,
Rafal
Re: javascript: toLocaleDateString and BIRT datetime functions [message #500339 is a reply to message #500154] Wed, 25 November 2009 16:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Rafal,

This function returns a java.util.Date not a js date.

If you use a text element or data element all you have to enter is:
Data
BirtDateTime.addDay(new Date(),-1);
text
<VALUE-OF>BirtDateTime.addDay(new Date(),-1);</VALUE-OF>
In both cases the date is automatically formated for the current locale

If you have to use a dynamic text element you could format like:
var dt =BirtDateTime.addDay(new Date(),-1);
importPackage( Packages.java.text );
var sdf = new SimpleDateFormat("MMM d, yyyy HH:mm aaa");
var mydtf1 = sdf.format(dt );
mydtf1;

Jason

Rafal Wojtowicz wrote:
> Hi,
> In my dynamic text field I have a script:
>
> BirtDateTime.addDay(new Date(),-1).toLocaleDateString();
>
> which doesn't work because of an error:
>
> TypeError: Cannot find function toLocaleDateString in object Tue Nov 24
> 09:36:01 CET 2009. (<inline>#1)
>
> It seems like addDay method doesn't really return javascript DateTime
> object. Do you know how to solve this problem, or maybe have another
> easy way to show yesterday's date in my locale?
>
> Thanks,
> Rafal
icon4.gif  Re: javascript: toLocaleDateString and BIRT datetime functions [message #529454 is a reply to message #500339] Sun, 25 April 2010 19:09 Go to previous messageGo to next message
Ralph Gleason is currently offline Ralph GleasonFriend
Messages: 3
Registered: January 2010
Junior Member
Hi Jason,

I relation to this thread, I am wondering if you've seen or have an idea why I might be experiencing some strange AddDay() behavior? I have a simple Data binding in a report which looks something like:

if(params["RunDate"].value==null){BirtDateTime.addDay(new Date(),-90)}else{BirtDateTime.addDay(params["RunDate"].value,-90)};

If I use any day within the first week of April of any year, as my selected parameter value, the result will return a full year earlier. I'm not sure if this is something that was already addressed in a patch, but I don't see this on every version of BIRT. Sadly, it is only experienced within my clients BIRT deployments. Not my own.

Ideas?

Thanks,

Ralph G.
Re: javascript: toLocaleDateString and BIRT datetime functions [message #529635 is a reply to message #529454] Mon, 26 April 2010 15:15 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Ralph,

I have not seen this. What version are your clients running?

Jason


On 4/25/2010 3:09 PM, Ralph Gleason wrote:
> Hi Jason,
> I relation to this thread, I am wondering if you've seen or have an idea
> why I might be experiencing some strange AddDay() behavior? I have a
> simple Data binding in a report which looks something like:
> if(params["RunDate"].value==null){BirtDateTime.addDay(new
> Date(),-90)}else{BirtDateTime.addDay(params["RunDate"].value,-90)};
>
> If I use any day within the first week of April of any year, as my
> selected parameter value, the result will return a full year earlier.
> I'm not sure if this is something that was already addressed in a patch,
> but I don't see this on every version of BIRT. Sadly, it is only
> experienced within my clients BIRT deployments. Not my own.
> Ideas?
> Thanks,
> Ralph G.
Re: javascript: toLocaleDateString and BIRT datetime functions [message #1745237 is a reply to message #529635] Thu, 06 October 2016 19:08 Go to previous message
Ralph Gleason is currently offline Ralph GleasonFriend
Messages: 3
Registered: January 2010
Junior Member
This was a caps issue on the month format.
Previous Topic:Chart interactivity
Next Topic:Parameter Dialog slow to load
Goto Forum:
  


Current Time: Sat Apr 20 02:26:04 GMT 2024

Powered by FUDForum. Page generated in 0.03391 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top