8

I was looking at some book of system programming. It mentioned to use a variable TZ with a colon separated list which is used from /usr/share/zoneinfo. Probably the book is a bit outdated.

I checked on my Ubuntu system

/usr/share/zoneinfo/Asia$ file Oral

gives following output

Oral: timezone data, version 2, 14 gmt time flags, 14 std time flags, no leap seconds, 51 transition times, 14 abbreviation chars

I tried opening it in vi but the text could not be read. I also tried reading /etc/localtime but here also it could not be read.

  1. How can I basically read above type of files?

  2. Where is TZ environment variable defined in Ubuntu 10.04?

poolie
  • 9,161
  • 4
  • 38
  • 62
Registered User
  • 4,904
  • 11
  • 37
  • 43

1 Answers1

10

Well, it depends what you want to read it for?

Almost all programs just rely on $TZ being set in the environment or /etc/localtime being a link to a timezone file. The C library will then automatically arrange for eg localtime() to return the correct time.

1) How can I basically read above type of files

zdump -v /etc/localtime will show you what's inside the files.

These are compiled files not meant for humans to read. apt-get source tzdata will give you the source they come from.

2) Where is TZ environment variable defined in Ubuntu 10.04

It is not set by default. Instead, /etc/localtime is a copy of the relevant zoneinfo file, and /etc/timezone is the name of that zone.

You can change them with sudo tzconfig or through the GUI.

You could set it in for instance ~/.env if you want a different personal default for yourself.

poolie
  • 9,161
  • 4
  • 38
  • 62
  • Creating `~/.env` with `UTC` in it has no effect on the local timezone. – jfs Sep 05 '14 at 01:14
  • Nowadays it is tzselect – jiggunjer Feb 16 '17 at 23:33
  • `tzselect` is not a replacement for `tzconfig`: it just chooses a timezone and prints it to stdout _without changing any configuration_. The actual modern replacement is `dpkg-reconfigure tzdata`. – poolie Feb 17 '17 at 16:39