open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Examining TimeZone data in Solaris

ITworld.com 2/16/2007

Sandra Henry-Stocker, ITworld.com

Send in your Unix questions today! | See additional Unix tips and tricks

In last week's column, I encouraged anyone who hasn't already patched their OSes for the imminent daylight savings time changes. This week, we look at a command for displaying timezone data and verifying the date on which the switch to DST will be made.

The command is zdump. In its simplest form, zdump displays the current time for whatever timezone is requested. For example, in the commands below, you can see that EST is five hours behind UTC (Universal Time). The output of the zdump command is almost identical to that of the date command, but includes the timezone at the start of the line.
> zdump EST
EST  Sat Feb  3 14:28:00 2007 EST
> zdump UTC
UTC  Sat Feb  3 19:28:00 2007 UMT
> date
Sat Feb  3 14:28:00 EST 2007
You can also use the zdump command with timezone files for various regions of the world:
> zdump US/Eastern
US/Eastern  Sat Feb  3 14:39:33 2007 EST
> zdump /usr/share/lib/zoneinfo/Australia/North
/usr/share/lib/zoneinfo/Australia/North  Sun Feb  4 05:09:33 2007 CST
> zdump Singapore
Singapore  Sun Feb  4 03:39:33 2007 SGT\
If you add a -v (verbose) argument to your zdump command, the command will display all of the information in the otherwise unreadable zone file. For many zones, this will be far more information than you want to see. The output below shows only bottom lines from the zdump output for US/Eastern. Notice how the data stops in 2038:
US/Eastern  Sun Nov  2 05:59:59 2036 UTC = Sun Nov  2 01:59:59 2036 EDT isdst=1
US/Eastern  Sun Nov  2 06:00:00 2036 UTC = Sun Nov  2 01:00:00 2036 EST isdst=0
US/Eastern  Sun Mar  8 06:59:59 2037 UTC = Sun Mar  8 01:59:59 2037 EST isdst=0
US/Eastern  Sun Mar  8 07:00:00 2037 UTC = Sun Mar  8 03:00:00 2037 EDT isdst=1
US/Eastern  Sun Nov  1 05:59:59 2037 UTC = Sun Nov  1 01:59:59 2037 EDT isdst=1
US/Eastern  Sun Nov  1 06:00:00 2037 UTC = Sun Nov  1 01:00:00 2037 EST isdst=0
US/Eastern  Tue Jan 19 03:14:07 2038 UTC = Mon Jan 18 22:14:07 2038 EST isdst=0
US/Eastern  Mon Jan 18 03:14:07 2038 UTC = Sun Jan 17 22:14:07 2038 EST isdst=0
This output also tells you that daylight savings time in the US/Eastern timezone in 2037 will start on March 8th. The isdst=0 (read "is dst") and isdst=1 indicate the transition from standard time to daylight savings.

To examine daylight savings times transitions for New York City (this is the same as US/Eastern), you can use the zdump command and grep on the year:
# zdump -v America/New_York | grep 2007
America/New_York  Fri Jan 26 21:33:07 2007 UTC = Fri Jan 26 16:33:07 2007 EST isdst=0
America/New_York  Sun Mar 11 06:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 EST isdst=0
America/New_York  Sun Mar 11 07:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 EDT isdst=1
America/New_York  Sun Nov  4 05:59:59 2007 UTC = Sun Nov  4 01:59:59 2007 EDT isdst=1
America/New_York  Sun Nov  4 06:00:00 2007 UTC = Sun Nov  4 01:00:00 2007 EST isdst=0
This output shows that daylight savings starts on March 11th and ends on November 4th.

Don't try your own city or region unless you find it in the /usr/share/lib/zoneinfo/America directory or the /usr/share/lib/zoneinfo/ directory.

If you're interested in determining the day that the change will take place next year or 10 years from now, you can try a command similar to those below:
# zdump -v Canada/Eastern | grep 2008
Canada/Eastern  Sun Mar  9 06:59:59 2008 UTC = Sun Mar  9 01:59:59 2008 EST isdst=0
Canada/Eastern  Sun Mar  9 07:00:00 2008 UTC = Sun Mar  9 03:00:00 2008 EDT isdst=1
Canada/Eastern  Sun Nov  2 05:59:59 2008 UTC = Sun Nov  2 01:59:59 2008 EDT isdst=1
Canada/Eastern  Sun Nov  2 06:00:00 2008 UTC = Sun Nov  2 01:00:00 2008 EST isdst=0

# zdump -v Europe/Nicosia | grep 2018
Europe/Nicosia  Sun Mar 25 00:59:59 2018 UTC = Sun Mar 25 02:59:59 2018 EET isdst=0
Europe/Nicosia  Sun Mar 25 01:00:00 2018 UTC = Sun Mar 25 04:00:00 2018 EEST isdst=1
Europe/Nicosia  Sun Oct 28 00:59:59 2018 UTC = Sun Oct 28 03:59:59 2018 EEST isdst=1
Europe/Nicosia  Sun Oct 28 01:00:00 2018 UTC = Sun Oct 28 03:00:00 2018 EET isdst=0

On this topic

 

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
TRY NEW SUN SERVERS FREE for 60 Days!
Test The Latest Sun Servers In Your Environment BEFORE YOU BUY. Pay Nothing, Not Even Shipping.
Workflow Enabled Help Desk & IT Service Management
Automate service desk activities and integrate processes across IT. Learn more here.
Sign up for a FREE NETWORK RISK ASSESSMENT!
MORE THAN 70% OF NETWORKS ARE INFECTED by hidden Malware. Find out if your network is infected now!
Enterprise IP Goes Mobile
To maximize full productivity, companies must integrate their mobile applications with the IP network.
» Buy a link now

Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
Locate Hidden Software on business PCs with this free tool
KODAK i1400 Series Scanners stand up to the challenge
Bring harmony to your mix of UNIX-Linux-Windows computing environments
 Home   Open source
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.