> the way I did it was:
> 
> date -d '70-1-1 0:0:1000000000'
> Sun Sep 9 01:46:40 2001

Wow, smart! I love it. It's even portable - reading up on K&R ANSI says
that for the time.h functions, out-of-range values must be normalised
by adjusting the other values accordingly.

It still probably only works with GNU date. Solaris 2.7 date has neither
-d nor -r, what a laugh, but my considered opinion of the basic Solaris
utilities for a long time has been what nzlug calls a "steaming heap of
cow dung". Or else POSIX in this department is brain-damaged.

Btw you are missing a -u switch there, time_t values are always(!) UTC.

The remaing part of the exercise then becomes:

#!/bin/sh
if [ $# -lt 1 ]; then
    echo "Give a time_t value to print."
    exit 1
fi
python -c \
"import time;print time.strftime('%a %b %e %T %Z %Y',time.localtime($1))"
#"import time;print time.strftime('%a, %d %b %Y %H:%M:%S',time.localtime($1))"
date -u -d "70-1-1 0:0:$1"
date -d "`date -u -d "70-1-1 0:0:$1"`"

$ time_t2readable 1000000000
Sun Sep  9 13:46:40 NZST 2001
Sun Sep  9 01:46:40 UTC 2001
Sun Sep  9 13:46:40 NZST 2001

The Linux strftime man page is wrong, the %+ doesn't exist.

Thanks all,

Volker

-- 
Volker Kuhlmann                 is possibly list0570 with the domain in header
http://volker.dnsalias.net/             Please do not CC list postings to me.

Reply via email to