>  Docs Center  >  Libraries  >  Markwardt  >  TZOFFSET

TZOFFSET

TZOFFSET

Name


  TZOFFSET

Author


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

Purpose


  Compute timezone offset from GMT for any date

Calling Sequence


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

Description



  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.

Methods



  Since IDL does not provide 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
  transitions.
  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.
  CAVEATS:
  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
  2038.
  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
  something.

Parameters



  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.

Returns



  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
          timezone.
          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



  SYSTIME

Modification History


  Written, CM, 14 Sep 2009
  Documentation typos, CM, 25 Sep 2012
  $Id: tzoffset.pro,v 1.6 2012/09/27 23:17:28 cmarkwar Exp $



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