Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    changing browser timezome

    We've received a request to be able to change the browser's timezone dynamically - Is there any way to do this in SmartClient?

    #2
    You can set the timezone used for showing all times via Time.setDefaultDisplayTimezeone(). The actual browser setting for timezone is a system setting that a web page cannot change.

    Comment


      #3
      Currently for date-time fields, before we send the data back to the server, we re-set it to GMT 00:00 and then on the server side, we re-set it to the server time. The process of doing this uses the javascript date object to get the timezone offset. If we start using Time.setDefaultDisplayTimezone(), we need to figure out the timezone offset based on this timezone instead of the browser timezone. Is there any out-of-box way of doing this? Or do we need to do the calculation ourselves?

      Comment


        #4
        We're not sure why you'd take that approach, but yes, if you're doing that, you'll need to do manual calculation.

        Comment


          #5
          I need some clarification with the Time class. I'd like to be able to create a new date instance using the timezone I have set on the Time class. I tried the following code but it gives me a date marked as -5:00GMT - I know createDate() is deprecrated but not sure what else to use.

          Code:
          isc.Time.setDefaultDisplayTimezone("-3:30");
          isc.IButton.create({
              left:120, top:240,
              title:"Rollover off",
              click:"isc.warn(isc.Time.createDate());"
          })

          Comment


            #6
            One approach is to call Time.parseInput(), which interprets the value as though the user had typed it.

            Comment


              #7
              parseInput does not seem to change the timezone according to the default that I have specified? I want to be able to specify new Date() converted into -3:30 timezone

              Code:
              isc.Time.setDefaultDisplayTimezone("-3:30");
              isc.IButton.create({
                  left:120, top:240,
                  title:"Rollover off",
                  click:"alert(isc.Time.parseInput('1:00pm'));"
              })

              Comment


                #8
                Sorry, to clarify, a "time" value is a pure logical time with no meaningful day value or locale - it is not sensitive to timezone.

                So what exactly do you want - a "date", "datetime" or "time" value?

                And what specifically do you mean by it being "in" a given timezone? Generally a "datetime" value should be transmitted as epoch timestamp or a UTC String to minimize ambiguity. Then it can be *displayed* in various timezones but the value itself is not "in" a timezone and is not "converted" - it doesn't change, it's just displayed various ways. So please be specific about exactly what you want.

                Comment


                  #9
                  What I want to do is what JavaScript Date.getTimezoneOffset() does - Returns the time difference between GMT and local time, in minutes...but instead of using the browser timezone, I want to use the default timezone I have set using isc.Time.setdefaultTimezone()

                  Comment


                    #10
                    OK, we don't really have a shortcut for that relative to: parsing the string you pass to setDefaultTimezone() into a milliseconds value, and doing math with that and the result of Date.getTimezoneOffset().

                    Comment

                    Working...
                    X