hubertf's NetBSD Blog
Send interesting links to hubert at feyrer dot de!
 
[20091024] Fun around daylight saving time (DST) and Unix timezone handling in general
It's that time of the year again when I and my friends never know when daylight saving time is switched from summer- to winter time. Do you know? And if you've heared in the news today... do you know when the next change is?

There's an easy way to find out, using the zdump(8) utility that comes with about every Unix machine (at least with NetBSD and Mac OS X - is there anything else relevant? :), and the timezone information stored in the /usr/share/zoneinfo directory.

To find out when DST is switched on/off, run the following command:

% zdump -v /etc/localtime
...
/etc/localtime  Sun Mar 29 00:59:59 2009 UTC = Sun Mar 29 01:59:59 2009 CET isdst=0
/etc/localtime  Sun Mar 29 01:00:00 2009 UTC = Sun Mar 29 03:00:00 2009 CEST isdst=1
/etc/localtime  Sun Oct 25 00:59:59 2009 UTC = Sun Oct 25 02:59:59 2009 CEST isdst=1
/etc/localtime  Sun Oct 25 01:00:00 2009 UTC = Sun Oct 25 02:00:00 2009 CET isdst=0
/etc/localtime  Sun Mar 28 00:59:59 2010 UTC = Sun Mar 28 01:59:59 2010 CET isdst=0
/etc/localtime  Sun Mar 28 01:00:00 2010 UTC = Sun Mar 28 03:00:00 2010 CEST isdst=1
/etc/localtime  Sun Oct 31 00:59:59 2010 UTC = Sun Oct 31 02:59:59 2010 CEST isdst=1
/etc/localtime  Sun Oct 31 01:00:00 2010 UTC = Sun Oct 31 02:00:00 2010 CET isdst=0
/etc/localtime  Sun Mar 27 00:59:59 2011 UTC = Sun Mar 27 01:59:59 2011 CET isdst=0
/etc/localtime  Sun Mar 27 01:00:00 2011 UTC = Sun Mar 27 03:00:00 2011 CEST isdst=1
/etc/localtime  Sun Oct 30 00:59:59 2011 UTC = Sun Oct 30 02:59:59 2011 CEST isdst=1
/etc/localtime  Sun Oct 30 01:00:00 2011 UTC = Sun Oct 30 02:00:00 2011 CET isdst=0
...  
The data is given relative to Universal Time Coordinated, which you can determine on a NetBSD system by running "date -u":
% date
Sat 24 Oct 14:30:24 CEST 2009
% date -u
Sat 24 Oct 12:30:26 UTC 2009
And if you wonder what timezone you're actually in, you probably knokw that /etc/localtime is a symbolic link to a file that fits to your exact timezone, with all related information:
% ls -la /etc/localtime 
lrwxr-xr-x  1 root  wheel  33 May 26  2007 /etc/localtime -> /usr/share/zoneinfo/Europe/Berlin
If you always wanted to know what timezones there are, have a look at /usr/share/zoneinfo:
% ls /usr/share/zoneinfo/
Africa       Chile        GB-Eire      Israel       NZ-CHAT      UCT
America      Cuba         GMT          Jamaica      Navajo       US
Antarctica   EET          GMT+0        Japan        PRC          UTC
Arctic       EST          GMT-0        Kwajalein    PST8PDT      Universal
Asia         EST5EDT      GMT0         Libya        Pacific      W-SU
Atlantic     Egypt        Greenwich    MET          Poland       WET
Australia    Eire         HST          MST          Portugal     Zulu
Brazil       Etc          Hongkong     MST7MDT      ROC          iso3166.tab
CET          Europe       Iceland      Mexico       ROK          posixrules
CST6CDT      Factory      Indian       Mideast      Singapore    zone.tab
Canada       GB           Iran         NZ           Turkey
% ls /usr/share/zoneinfo/Europe/
Amsterdam    Chisinau     Kiev         Moscow       Sarajevo     Vatican
Andorra      Copenhagen   Lisbon       Nicosia      Simferopol   Vienna
Athens       Dublin       Ljubljana    Oslo         Skopje       Vilnius
Belfast      Gibraltar    London       Paris        Sofia        Volgograd
Belgrade     Guernsey     Luxembourg   Podgorica    Stockholm    Warsaw
Berlin       Helsinki     Madrid       Prague       Tallinn      Zagreb
Bratislava   Isle_of_Man  Malta        Riga         Tirane       Zaporozhye
Brussels     Istanbul     Mariehamn    Rome         Tiraspol     Zurich
Bucharest    Jersey       Minsk        Samara       Uzhgorod
Budapest     Kaliningrad  Monaco       San_Marino   Vaduz 
So now that we all that, here's a last cutie: suppose you want to log into a machine on the other end of the world, and still run an application that should use your local timezone, not that that the machine is in. Changing /etc/localtime is not an option, but you can do it on a per-process base by setting the "TZ" environment variable:
% date
Sat Oct 24 14:35:06 CEST 2009
% ssh remote.example.org date
Sat Oct 24 12:35:45 UTC 2009
% ssh remote.example.org env TZ=Europe/Berlin date
Sat Oct 24 14:35:58 CEST 2009 
Enjoy!

[Tags: , , , , ]


[20070228] Daylight Saving Time Changes: Nothing new for NetBSD
Jan Schauman has posted an announcement on the recent daylight saving time excitement: `` Daylight Saving Time (DST) was extended in a number of countries starting in 2007. For example, beginning in 2007, most of the USA will begin Daylight Saving Time at 2:00 a.m. on the second Sunday in March and revert to standard time on the first Sunday in November. While this has caused a number of software vendors a lot of headache, NetBSD has shipped with the appropriate timezone files for years; even though changes to timezones in general and DST rules in particular happen a few times a year throughout the world, the NetBSD operating system has of course always provided accurate and up to date zone files as soon as possible.

The Energy Policy Act of 2005 was signed into USA law on August 8, 2005. The updated tzdata package (tzdata2005m) was imported into our source tree on August 29, 2005, and was pulled up into the netbsd-2 (September 5, 2005), netbsd-2-0 and netbsd-3 (both September 6, 2005) branches and is thus present in NetBSD 2.0.3, 2.1, 3.0, 3.0.1, 3.1 and the 4.x branches.

In other words, if you're running one of these systems, no action on your part is required; your system is already prepared for the updated timezones and will continue to show the correct local time. ''

You can read the full text either in his mail, or in the news item on the NetBSD website.

[Tags: , ]


Tags: , 2bsd, 34c3, 3com, 501c3, 64bit, acl, acls, acm, acorn, acpi, acpitz, adobe, adsense, Advocacy, advocacy, advogato, aes, afs, aiglx, aio, airport, alereon, alex, alix, alpha, altq, am64t, amazon, amd64, anatomy, ansible, apache, apm, apple, arkeia, arla, arm, art, Article, Articles, ascii, asiabsdcon, aslr, asterisk, asus, atf, ath, atheros, atmel, audio, audiocodes, autoconf, avocent, avr32, aws, axigen, azure, backup, balloon, banners, basename, bash, bc, beaglebone, benchmark, bigip, bind, blackmouse, bldgblog, blog, blogs, blosxom, bluetooth, board, bonjour, books, boot, boot-z, bootprops, bozohttpd, bs2000, bsd, bsdca, bsdcan, bsdcertification, bsdcg, bsdforen, bsdfreak, bsdmac, bsdmagazine, bsdnexus, bsdnow, bsdstats, bsdtalk, bsdtracker, bug, build.sh, busybox, buttons, bzip, c-jump, c99, cafepress, calendar, callweaver, camera, can, candy, capabilities, card, carp, cars, cauldron, ccc, ccd, cd, cddl, cdrom, cdrtools, cebit, centrino, cephes, cert, certification, cfs, cgd, cgf, checkpointing, china, christos, cisco, cloud, clt, cobalt, coccinelle, codian, colossus, common-criteria, community, compat, compiz, compsci, concept04, config, console, contest, copyright, core, cortina, coverity, cpu, cradlepoint, cray, crosscompile, crunchgen, cryptography, csh, cu, cuneiform, curses, curtain, cuwin, cvs, cvs-digest, cvsup, cygwin, daemon, daemonforums, daimer, danger, darwin, data, date, dd, debian, debugging, dell, desktop, devd, devfs, devotionalia, df, dfd_keeper, dhcp, dhcpcd, dhcpd, dhs, diezeit, digest, digests, dilbert, dirhash, disklabel, distcc, dmesg, Docs, Documentation, donations, draco, dracopkg, dragonflybsd, dreamcast, dri, driver, drivers, drm, dsl, dst, dtrace, dvb, ec2, eclipse, eeepc, eeepca, ehci, ehsm, eifel, elf, em64t, Embedded, embedded, emips, emulate, encoding, envsys, eol, espresso, etcupdate, etherip, euca2ools, eucalyptus, eurobsdcon, eurosys, Events, exascale, ext3, f5, facebook, falken, fan, faq, fatbinary, features, fefe, ffs, filesystem, fileysstem, firefox, firewire, fireworks, flag, flash, flashsucks, flickr, flyer, fmslabs, force10, fortunes, fosdem, fpga, freebsd, freedarwin, freescale, freex, freshbsd, friendlyAam, friendlyarm, fritzbox, froscamp, fsck, fss, fstat, ftp, ftpd, fujitsu, fun, fundraising, funds, funny, fuse, fusion, g4u, g5, galaxy, games, gcc, gdb, gentoo, geode, getty, gimstix, git, gnome, google, google-soc, googlecomputeengine, gpio, gpl, gprs, gracetech, gre, groff, groupwise, growfs, grub, gumstix, guug, gzip, hackathon, hackbench, hal, hanoi, happabsd, hardware, Hardware, haze, hdaudio, heat, heimdal, hf6to4, hfblog, hfs, history, hosting, hotplug, hp, hp700, hpcarm, hpcsh, hpux, html, httpd, hubertf, hurd, i18n, i386, i386pkg, ia64, ian, ibm, ids, ieee, ifwatchd, igd, iij, image, images, imx233, imx7, information, init, initrd, install, intel, interix, internet2, interview, interviews, io, ioccc, iostat, ipbt, ipfilter, ipmi, ipplug, ipsec, ipv6, irbsd, irc, irix, iscsi, isdn, iso, isp, itojun, jail, jails, japanese, java, javascript, jetson, jibbed, jihbed, jobs, jokes, journaling, kame, kauth, kde, kerberos, kergis, kernel, keyboardcolemak, kirkwood, kitt, kmod, kolab, kvm, kylin, l10n, landisk, laptop, laptops, law, ld.so, ldap, lehmanns, lenovo, lfs, libc, license, licensing, linkedin, links, linksys, linux, linuxtag, live-cd, lkm, localtime, locate.updatedb, logfile, logging, logo, logos, lom, lte, lvm, m68k, macmini, macppc, macromedia, magicmouse, mahesha, mail, makefs, malo, mame, manpages, marvell, matlab, maus, max3232, mbr95, mbuf, mca, mdns, mediant, mediapack, meetbsd, mercedesbenz, mercurial, mesh, meshcube, mfs, mhonarc, microkernel, microsoft, midi, mini2440, miniroot, minix, mips, mirbsd, missile, mit, mixer, mobile-ip, modula3, modules, money, mouse, mp3, mpls, mprotect, mtftp, mult, multics, multilib, multimedia, music, mysql, named, nas, nasa, nat, ncode, ncq, ndis, nec, nemo, neo1973, netbook, netboot, netbsd, netbsd.se, nethack, nethence, netksb, netstat, netwalker, networking, neutrino, nforce, nfs, nis, npf, npwr, nroff, nslu2, nspluginwrapper, ntfs-3f, ntp, nullfs, numa, nvi, nvidia, nycbsdcon, office, ofppc, ohloh, olimex, olinuxino, olpc, onetbsd, openat, openbgpd, openblocks, openbsd, opencrypto, opendarwin, opengrok, openmoko, openoffice, openpam, openrisk, opensolaris, openssl, or1k, oracle, oreilly, oscon, osf1, osjb, paas, packages, pad, pae, pam, pan, panasonic, parallels, pascal, patch, patents, pax, paypal, pc532, pc98, pcc, pci, pdf, pegasos, penguin, performance, pexpect, pf, pfsync, pgx32, php, pie, pike, pinderkent, pkg_install, pkg_select, pkgin, pkglint, pkgmanager, pkgsrc, pkgsrc.se, pkgsrccon, pkgsrcCon, Platforms, plathome, pleiades, pocketsan, podcast, pofacs, politics, polls, polybsd, portability, posix, postinstall, power3, powernow, powerpc, powerpf, pppoe, precedence, preemption, prep, presentations, prezi, Products, products, proplib, protectdrive, proxy, ps, ps3, psp, psrset, pthread, ptp, ptyfs, Publications, puffs, puredarwin, pxe, qemu, qnx, qos, qt, quality-management, quine, quote, quotes, r-project, ra5370, radio, radiotap, raid, raidframe, rants, raptor, raq, raspberrypi, rc.d, readahead, realtime, record, refuse, reiserfs, Release, Releases, releases, releng, reports, resize, restore, ricoh, rijndael, rip, riscos, rng, roadmap, robopkg, robot, robots, roff, rootserver, rotfl, rox, rs323, rs6k, rss, ruby, rump, rzip, sa, safenet, san, sata, savin, sbsd, scampi, scheduler, scheduling, schmonz, sco, screen, script, sdf, sdtemp, secmodel, security, Security, sed, segvguard, seil, sendmail, serial, serveraptor, sfu, sge, sgi, sgimips, sh, sha2, shark, sharp, shisa, shutdown, sidekick, size, slackware, slashdot, slides, slit, smbus, smp, sockstat, soekris, softdep, softlayer, software, solaris, sony, sound, source, source-changes, spanish, sparc, sparc64, spider, spreadshirt, spz, squid, ssh, sshfs, ssp, statistics, stereostream, stickers, storage, stty, studybsd, subfile, sudbury, sudo, summit, sun, sun2, sun3, sunfire, sunpci, support, sus, suse, sushi, susv3, svn, swcrypto, symlinks, sysbench, sysctl, sysinst, sysjail, syslog, syspkg, systat, systrace, sysupdate, t-shirt, tabs, talks, tanenbaum, tape, tcp, tcp/ip, tcpdrop, tcpmux, tcsh, teamasa, tegra, teredo, termcap, terminfo, testdrive, testing, tetris, tex, TeXlive, thecus, theopengroup, thin-client, thinkgeek, thorpej, threads, time, time_t, timecounters, tip, tk1, tme, tmp, tmpfs, tnf, toaster, todo, toolchain, top, torvalds, toshiba, touchpanel, training, translation, tso, tty, ttyrec, tulip, tun, tuning, uboot, ucom, udf, ufs, ukfs, ums, unetbootin, unicos, unix, updating, upnp, uptime, usb, usenix, useradd, userconf, userfriendly, usermode, usl, utc, utf8, uucp, uvc, uvm, valgrind, vax, vcfe, vcr, veriexec, vesa, video, videos, virtex, virtualization, vm, vmware, vnd, vobb, voip, voltalinux, vpn, vpnc, vulab, w-zero3, wallpaper, wapbl, wargames, wasabi, webcam, webfwlog, wedges, wgt624v3, wiki, willcom, wimax, window, windows, winmodem, wireless, wizd, wlan, wordle, wpa, wscons, wstablet, X, x.org, x11, x2apic, xbox, xcast, xen, Xen, xfree, xfs, xgalaxy, xilinx, xkcd, xlockmore, xmms, xmp, xorg, xscale, youos, youtube, zaurus, zdump, zfs, zlib

'nuff. Grab the RSS-feed, index, or go back to my regular NetBSD page

Disclaimer: All opinion expressed here is purely my own. No responsibility is taken for anything.

Access count: 36036062
Copyright (c) Hubert Feyrer