diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-11-30 19:57:20 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-11-30 19:57:20 -0500 |
commit | 8ff1a86005121edcbf04cfaf8f0812591cb916c6 (patch) | |
tree | c8e9ac06ad48378c0b853e42e00284f71e787a68 /debugfs/util.c | |
parent | 3838f7df134035089e8e8df317112e4fd645602d (diff) | |
download | e2fsprogs-8ff1a86005121edcbf04cfaf8f0812591cb916c6.tar.gz |
If the TZ environment variable is set to GMT, use gmtime()
instead of localtime() or ctime() to force the use of GMT.
This is because the dietlibc doesn't honor the TZ environment
variable.
Diffstat (limited to 'debugfs/util.c')
-rw-r--r-- | debugfs/util.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/debugfs/util.c b/debugfs/util.c index 0c1cfed5..ea82e324 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -187,8 +187,14 @@ int check_fs_bitmaps(char *name) char *time_to_string(__u32 cl) { time_t t = (time_t) cl; + static int do_gmt = -1; - return ctime(&t); + if (do_gmt == -1) { + /* The diet libc doesn't respect the TZ environemnt variable */ + do_gmt = !strcmp(getenv("TZ"), "GMT"); + } + + return asctime((do_gmt) ? gmtime(&t) : localtime(&t)); } /* |