web stats
Code Template Error - Date().getTimezoneOffset() - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-16-2012, 09:22 AM
WickedOne WickedOne is offline
Mirth Newb
 
Join Date: Jun 2012
Posts: 7
WickedOne is on a distinguished road
Default Code Template Error - Date().getTimezoneOffset()

Any help would be great!

I am currently is running a code template in production and it's been great. No failure.

I have made changes to an interface and put it in testing mode. During testing mode i'm getting the following error from the code template I have mentioned.

sourceConnectorSCRIPT SOURCE:
SOURCE CODE:
3466:
}3467: }// modify function_name and parameters as you wish.3468: // one function per template is recommended. i.e.) create a new code template for each new function.3469: function CheckDayLightSaving()3470: {3471:
return this.getTimezoneOffset() < this.stdTimezoneOffset();3472: }3473: 3474: function stdTimezoneOffset()3475: {LINE NUMBER:
3471DETAILS:
TypeError: Cannot find function getTimezoneOffset in object [object Object].



HERE IS THE CODE TEMPLATE: 3 Functions in one Code Template.



//Function is to convert date to Partner's timezone date.
function FormatDateToPartner(offSetTimeZone, dateTime)
{
logger.info('Date =' + dateTime);
var examDateUTC = DateUtil.getDate("yyyy-MM-dd'T'HH:mm:ss'Z'", dateTime);

if(this.CheckDayLightSaving() == false)
{
offSetTimeZone = (60 + parseInt(offSetTimeZone));
}

//Depending on the partner's location, offsetTimeZone could be positive or negative
var examDateLocal = new Date(examDateUTC.getTime() + (offSetTimeZone * 60000));
examDate = DateUtil.formatDate("yyyyMMddHHmmss", examDateLocal);

return examDate;
}

function CheckDayLightSaving()
{
//if equal then it is standard time, if not it's day light saving time
var test = new Date().getTimezoneOffset() == this.StandardTimezoneOffset();
return test;
}

function StandardTimezoneOffset()
{
//Get standard Timezone Offset
var jan = new Date;
jan.setMonth(0);
jan.setDate(1);

var jul = new Date;
jul.setMonth(6);
jul.setDate(1);

return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}
Reply With Quote
  #2  
Old 10-16-2012, 09:33 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

It looks like the code template you're using and the code you posted are different. The one I see in the RhinoException is:

Code:
function CheckDayLightSaving() {
	return this.getTimezoneOffset() < this.stdTimezoneOffset();
}
It's failing because the global scope doesn't have "getTimezoneOffset" defined. It looks like you intended to add that function to the Date prototype or something? Did you actually do that? If you forgot to add it to the prototype that error would occur as well.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 10-16-2012, 10:40 AM
WickedOne WickedOne is offline
Mirth Newb
 
Join Date: Jun 2012
Posts: 7
WickedOne is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
It looks like the code template you're using and the code you posted are different. The one I see in the RhinoException is:

Code:
function CheckDayLightSaving() {
	return this.getTimezoneOffset() < this.stdTimezoneOffset();
}
It's failing because the global scope doesn't have "getTimezoneOffset" defined. It looks like you intended to add that function to the Date prototype or something? Did you actually do that? If you forgot to add it to the prototype that error would occur as well.
There was a code template with that has the same function name as, "CheckDayLightSaving()".

I deleted that code template so it's not being called and now the interface is working.

thanks for you help! appreciate it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:06 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation