Bug 191113 - date -Rud '1970-01-01 UTC + 1147104611 sec + 0100' fails
date -Rud '1970-01-01 UTC + 1147104611 sec + 0100' fails
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-08 18:55 EDT by David Woodhouse
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-05-15 10:36:50 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Woodhouse 2006-05-08 18:55:15 EDT
In FC4, it gives the result: Mon, 08 May 2006 17:10:11 +0000
In FC5, it fails.

If's it's not _intended_ to work like that, please suggest an alternative way of
converting seconds since 1970-01-01 UTC and a timezone into a localtime in that
timezone. What we currently have is:

	sec=${date[0]}; tz=${date[1]}
	dtz=${tz/+/+ }; dtz=${dtz/-/- }
	pdate="$(date -Rud "1970-01-01 UTC + $sec sec $dtz" 2>/dev/null)"
Comment 1 David Woodhouse 2006-05-08 19:03:44 EDT
Sorry, that wasn't complete. It's this...

	sec=${date[0]}; tz=${date[1]}
	dtz=${tz/+/+ }; dtz=${dtz/-/- }
	pdate="$(date -Rud "1970-01-01 UTC + $sec sec $dtz" 2>/dev/null)"
	echo ${pdate/+0000/$tz}
Comment 2 Tim Waugh 2006-05-15 10:36:50 EDT
How about this?:

date -Rd 'TZ="GMT+0100" 1970-01-01 UTC + 1147104611 sec'

i.e. no -u option, and put TZ="..." at the start of the operand.
Comment 3 David Woodhouse 2006-05-15 10:53:20 EDT
Even more baroque than the original... but works. Thanks :)
Comment 4 Jim Meyering 2006-05-15 13:11:10 EDT
If you can depend on coreutils-5.3.0 or newer, then using the `-d@N_SECS'
notation is nice:

$ date -Rd @1147104611
Mon, 08 May 2006 18:10:11 +0200
$ date -Rd 'TZ="GMT+0100" 1970-01-01 UTC + 1147104611 sec'
Mon, 08 May 2006 18:10:11 +0200

Note You need to log in before you can comment on or make changes to this bug.