Quote:
Originally Posted by jlinkels
Code:
jlinkels@jlinkels-lt:~$ date --utc -d "2007-02-04 13:30:00 GMT-10 hours"
Sun Feb 4 03:30:00 UTC 2007
jlinkels@jlinkels-lt:~$ date --utc -d "2007-02-04 13:30:00 CET"
Sun Feb 4 12:30:00 UTC 2007
I am not sure what date does when you enter the TLA for GMT+10, but if you take the effort to enter GMT-10 hours in the date string it gives the correct UTC time.
Using the TLA for CET (GMT-1) does work.
jlinkels
|
Inspired by this, I came up with a one-line bash script that will entirely replace my Perl script.
Code:
date --utc -d "$* GMT-10 hours" +'%F %T'
I know, it says
GMT-10 instead of
GMT+10, but it does work for translating
GMT+10 to
UTC.
If, say, you store that one-line shell script as xxx in a directory in your
$PATH, you'll see output like this:
Code:
wally:~/thursday/2$ xxx 2009-01-25 20:57:22
2009-01-25 10:57:22
wally:~/thursday/2$ xxx 2009-01-25 10:57:22
2009-01-25 00:57:22
wally:~/thursday/2$ xxx 2009-01-25 00:57:22
2009-01-24 14:57:22
wally:~/thursday/2$