Using InfoPath (without code) to create time zone converter - InfoPath Dev
in

InfoPath Dev

Using InfoPath (without code) to create time zone converter

Last post 04-15-2013 06:39 AM by wilkies0106aw. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-12-2013 02:26 PM

    Using InfoPath (without code) to create time zone converter

    I have a need to publish a form to places around the world. The main InfoPath server is located in Houston Texas.  I do not have access to change anything on the server.

    The form has Start and End Times / Dates that need to be in the local time and date.  I need to be able to set the correct time and date based on the persons location (which i get from the SharePoint site location).   I have seen an InfoPath somewhere on the Internet that had rules that did the time / date conversions but i cannot find it.  Anyone out there that can assist?

    Thanks

  • 04-14-2013 10:41 PM In reply to

    Re: Using InfoPath (without code) to create time zone converter

    Hi Pete_Murphy,

    If you are using the InfoPath browser form, it will default to the server time zone.

    If you are using the InfoPath filler, it will default to the time zone of the user's machine where the form is being filled out.

    Assuming the browser (since the filler solves your problem by design), the key question is how do you get the time zone of the local user. Are they going to enter it, or do you want it to automatically select based on the site. If the latter, you'll have to have some business logic (no code needed) that queries the URL of the site. You can use xpath calculations to get the href attribute in the processing instruction for the current form and then use some substring wizardry to extract the site. If you have published separate form templates for each site, you could just hardcode the time zone in the form. Actually, you'd want to store the number of zones that separate the server from the site's time zone.  This will be an "hours off" difference. For example if your server is in Houston then it's GMT-5 when daylight savings is in effect and GMT-6 when it is not (you'll have to have rules in the form that handle daylight savings time for time zones that don't switch). Now, let's say your site is in Japan (which is GMT+9). So you're form will have an open rule which adds 14 or 15 hours to the current date time depending on whether daylight savings is in effect (just assume you add 15 hours but compare the current date to see if it's between the dates of daylight time savings and if so, subtract one hour).

    OK, so now, how do you add and subtract hours.  It's easy, just add a default value to your date-time field that uses the xpath function addSeconds. You'll want something like addSeconds(now(), 15*3600) to calculate the time 15 hours from now which is the default for Japan and Texas. Of course, it's daylight savings time you need to subtract 3600 so that's a rule that sets the value of your date-time field (assume the name is field1). Here's a sample of that: addSeconds(field1, -3600). Pretty simple stuff. No need for fancy date diff calculations that exclude holidays, weekends, etc.

    Good luck!

    Patrick Halstead
    Project Manager at Qdabra
  • 04-15-2013 06:39 AM In reply to

    Re: Using InfoPath (without code) to create time zone converter

     Instead of having default values in the fields. All I think you need to do is have form load rules using the now() function.

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.