Dealing with the current time

Finding or using the current time is useful for a number of purposes.

Quick Index:


Current time

IDL has a built-in routine to return the current time:

  print,systime()
     Thu May 19 10:55:34 1994

The returned result is a string containing the current date and time. It is useful for documentation, but not very useful for any kind of computation in this form. Tools for dealing with date/time strings are described later.

Universal Time

Universal time differs from local time by an amount depending on the local time zone and whether or not daylight savings is in effect. The JHU/APL/S1R library routine gmt_offsec returns the time difference in seconds:

  print,gmt_offsec()
          14400.0

The built-in help for this routine is:

  x=gmt_offsec(/help)   
   Return offset in seconds from local time to GMT (UT).
   off = gmt_offsec()
     off = offset in seconds from local time to GMT (UT).
   Note: Times are rounded to the nearest 1/4 hour.
     This should handle any time zone, even fractional ones.

Routines are described in a later section that make it easy to convert between date/time strings and numeric values, so the returned offset can be used to obtain the actual date and time for the current UT.

Local Mean Sidereal Time (LMST)

The local mean sidereal time is the Right Ascension of the local meridian in the sky and is of importance in astronomy. The JHU/APL/S1R library function lmst gives this value:

  x=lmst(/help)    
   Give local mean sidereal time.
   st = lmst( jd, ut, long)
     jd = Julian Day (starting at noon).         in
     ut = Universal time as fraction of day.     in
     long = observer longitude (deg, East is +). in
     st = sidereal time as fraction of day.      out

The Julian Day may be obtained from the year, month, day or a date/time string and will be discussed in a later section.

Sunlit earth map

The routine sunclock may be used to draw a map of the earth showing the point at which the sun is directly overhead, and daylight, twilight, and nighttime areas:

sunclock,/help
 Show world map with day, twilight, and night.
 sunclock, plat, plong
   plat = map projection central latitude (deg).
   plong = map projection central longitude (deg).
     West longitude < 0: 90 W = -90.
 Keywords:  map_set keywords may be given to control the map
   display.
   TIME=dt_tm  Specify a date and time.
     Format is flexible but requires month name (3 char min).
     Default is current system time. Ex: "1994 jun 22 13:45"
   ZONE=n  Specify a time zone as hours ahead of GMT.
     Default is local time zone.  Ex: zone=-4 for EDT.
     Only needed if in another time zone.
   /USA plots U.S. states.
 Notes: The meaning of the colors is as follows:
   Subsolar point: Red.
   Daylight: Yellow-Orange.
   Sun rise/set line: Red.
   Twilights: Pink, Blue, and Darker Blue bands.
     Civil:        Sun is   0 to  -6 degrees below horizon.
     Nautical:     Sun is  -6 to -12 degrees below horizon.
     Astronomical: Sun is -12 to -18 degrees below horizon.

Various map projections may be used. The example shown is the default. In this example the red sun symbol is plotted just east of the Bahamas. In case the colors do not show well here is a description of them. The color is bright yellow near the sun, smoothly grading to orange at the sun rise/set curve (which is red). The next three bands are Civil (pink), Nautical (blue), and Astronomical (darker blue) twilights.

Another interesting map projection is orthographic. The central latitude and longitude may be given to view the globe from any position. (See mapset for the needed keywords).


IDL main page.