>  Docs Center  >  Libraries  >  Markwardt  >  TZOFFSET






  Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770


  Compute timezone offset from GMT for any date

Calling Sequence

  DT = TZOFFSET(T, [/JULIAN,] [/LOCAL,] [IS_DST=is_dst])


  The function TZOFFSET computes the time zone offset between the
  local time zone and GMT for any date.
  The time zone offset is defined here as the number of seconds of
  time West of the Greenwich Meridian. Equivalently, it is the
  number of seconds that must be *added* to local time in order to
  transform it to GMT.
  Here are some examples for different time zones,
      Time zone TZOFFSET()
        UTC 0 ;; Britain
        GMT 0
        GMT-5 +18000 ;; United States
        GMT+10 -36000 ;; Australia
  The user may input the date, T, as either seconds elapsed since
  1970-01-01T00:00:00, or in Julian days (if /JULIAN is set). The
  input time may be either expressed in the user's local time zone
  (if /LOCAL is set) or in UTC.


  Since IDL does not a way to compute the time zone directly,
  TZOFFSET uses indirect methods.
  Essentially, it parses the output of SYSTIME(1) and
  SYSTIME(1,/UTC), and computes the time difference between the local
  system and UTC. There is a search algorithm that finds Summer-time
  For speed, TZOFFSET() pre-computes time zone offsets and saves them
  for future use as a table lookup. On a relatively modern computer
  in 2009, a century's worth of timezone data can be pre-computed in
  less than one second. If the time range of interest is smaller,
  then the pre-computations will occur more quickly than that. Once
  the table has been pre-computed, interpolation of the resulting
  table is extremely fast.
  The IS_DST output parameter is estimated using a heuristic.
  Basically, if TZOFFSET() increases, that is considered to be a
  summer-time transition, and if TZOFFSET() decreases, that is
  considered a transition to standard time.
  The results of TZOFFSET are only as good as your operating system's
  timezone information. If your system's timezone tables are
  incomplete or erroneous, then so will be TZOFFSET's output.
  TZOFFSET computes the timezone offsets for your system's current
  time-zone. To compute the offset for another different time zone,
  you will need to reset your system's notion of the timezone. On
  Unix and Mac OS X systems, this can be done by setting the "TZ"
  environment variable with SETENV.
  For 32-bit Unix systems, timezone tables apparently run out in
  Pre-computed timezone tables document Summer-time transitions to
  within one second. Users should avoid calling TZOFFSET() with
  times exactly on the transition boundaries.
  The IS_DST heuristic may not be perfect. It is better to rely on
  the actual timezone offset than to assume that IS_DST means


  T - input times, either array or scalar. The times may be
      in Julian days (if /JULIAN is set) or in seconds from
      1970-01-01T00:00:00. The times should be expressed in
      the UTC timezone, or the local time zone if /LOCAL is set.


  The resulting timezone offsets. The return value will
  have the same number of elements as the input T parameter.
  See CAVEATS above.

Keyword Parameters

  IS_DST - upon return, IS_DST is set to an array containing a
            boolean flag for each input time. If the flag equals 1,
            the corresponding input time is probably during "summer
            time." A flag value of 0 indicates probable
            standard time. See CAVEATS above.
  JULIAN - if set, then the input times must be in Julian days.
            DEFAULT: not set, i.e. input times are in seconds from 1970.
  LOCAL - if set, then the input times must be measured in the local
          DEFAULT: not set, i.e. input times are in UTC timezone.
  NOW - if set, then compute the timezone offset at the current
        moment. The values of T, JULIAN and LOCAL are ignored.

See Also


Modification History

  Written, CM, 14 Sep 2009

© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us