Bug 191113 - date -Rud '1970-01-01 UTC + 1147104611 sec + 0100' fails
Summary: date -Rud '1970-01-01 UTC + 1147104611 sec + 0100' fails
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-05-08 22:55 UTC by David Woodhouse
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-05-15 14:36:50 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description David Woodhouse 2006-05-08 22:55:15 UTC
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 23:03:44 UTC
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 14:36:50 UTC
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 14:53:20 UTC
Even more baroque than the original... but works. Thanks :)

Comment 4 Jim Meyering 2006-05-15 17:11:10 UTC
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.