I have reviewed some of the earlier posts regarding the issue of time zone conversions but I was hoping someone could scale it down for someone not as familiar with Javascript.
My task is to create a form that will calculate all of the hours to be paid for a business trip. I have code written to calculate the hours between the departure and arrival times. The issue I am having is in order to make the form more user friendly, I have a drop down list of all major time zones with major cities that the user will be able to select because most itineraries have local time which makes travelling out of multiple time zones difficult. I want to write a code that will automatically set both times (internally and not displayed to the user) to UTC or GMT time based on the time and time zone input, make the calculations that I created in the script I have already written and then display the total hours. As you can see I have the plan in my head but am unsure how to put it to 'paper'.
I only need help with the time zones because I am in over my head but I don't need anyone to write the code for me just hopefully will explain how I can implement these tools into an existing program that will calculate hours between departure and arrival without consideration into time zones. I have a feeling I will need to utilize the Olson database and possible GeoNames or Earthtools.
Olson Database
http://en.wikipedia.org/wiki/Zoneinfo
http://www.twinsun.com/tz/tz-link.htm
GeoNames
http://www.geonames.org/export/web-services.html#timezone
Earthtools
http://www.earthtools.org/webservices.htm#timezone
Solved! Go to Solution.
Views
Replies
Total Likes
I'm not sure but maybe if you were to set the timezone offset for the items in your dropdown list you could then use that value to correct to UTC or GMT or whatever. So on the Binding tab for your DDL you'd set the values under Specify Item Values, then you'd use the boundItem() method to retrieve the offset value.
That's just off the top of my head, I'm not sure I'd want to attempt writing something like this myself!
Views
Replies
Total Likes
I'm not sure but maybe if you were to set the timezone offset for the items in your dropdown list you could then use that value to correct to UTC or GMT or whatever. So on the Binding tab for your DDL you'd set the values under Specify Item Values, then you'd use the boundItem() method to retrieve the offset value.
That's just off the top of my head, I'm not sure I'd want to attempt writing something like this myself!
Views
Replies
Total Likes
Hi,
calculating times isn't trivial, especially when a form is used in another time zone that it was designed in.
Every timezone has a specific offset to the gmt time, which it the time zone XFA forms use as reference.
For Berlin it is for example -7200000 milliseconds (GMT+1) for New York its +14400000 milliseconds (GMT-5).
To avoid miscalculation you need to determine the time offset of your current lacation to gmt.
The easiest way is to use the locale property of your form ($template.#subform.locale), but this is not flexible enough as the template doesn't change at runtime anymore.
But better is to use the ambient locale of the host (Acrobat/Reader).
Here's a FormCalc script to calculate the time difference between two time considering the gmt offset of the current time zone of the host.
Thanks Jono, the problem I was having was not understanding all of LiveCycle's capabilities. I used that method and assigned the UTC offset for all airports and had it convert both user inputted times to UTC, calculate the difference and return hours comped. Thanks for the help.
As for the code you sent me radzmar I appreciate it, I already had so much code and starting over sounded like a daunting task so I went for the integrated method of boundItem. I'm sure your method would work (and probably be better than mine).
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies