bugGNU Core Utilities - Bugs: bug #16214, 'date -d' missets the hour using...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #16214: 'date -d' missets the hour using certain syntax

Submitted by:  Dallman Ross <dman>
Submitted on:  Wed 29 Mar 2006 12:13:55 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 29 Mar 2006 03:28:28 PM UTC, comment #1:

Hmm. It seems -- and this is thanks to Michael Polyemakos and Stephen Harris -- what I found isn't a bug, but an undocumented (I think) "feature":

a->i k->m == +1 -> +12 hours
n->y == -1 -> -12 hours

ie the result of TZ=UTC date -d "12:00 $v" where v changes is:
a --> Wed Mar 29 13:00:00 UTC 2006
b --> Wed Mar 29 14:00:00 UTC 2006
c --> Wed Mar 29 15:00:00 UTC 2006
d --> Wed Mar 29 16:00:00 UTC 2006
e --> Wed Mar 29 17:00:00 UTC 2006
f --> Wed Mar 29 18:00:00 UTC 2006
g --> Wed Mar 29 19:00:00 UTC 2006
h --> Wed Mar 29 20:00:00 UTC 2006
i --> Wed Mar 29 21:00:00 UTC 2006
k --> Wed Mar 29 22:00:00 UTC 2006
l --> Wed Mar 29 23:00:00 UTC 2006
m --> Thu Mar 30 00:00:00 UTC 2006
n --> Wed Mar 29 11:00:00 UTC 2006
o --> Wed Mar 29 10:00:00 UTC 2006
p --> Wed Mar 29 09:00:00 UTC 2006
q --> Wed Mar 29 08:00:00 UTC 2006
r --> Wed Mar 29 07:00:00 UTC 2006
s --> Wed Mar 29 06:00:00 UTC 2006
t --> Wed Mar 29 05:00:00 UTC 2006
u --> Wed Mar 29 04:00:00 UTC 2006
v --> Wed Mar 29 03:00:00 UTC 2006
w --> Wed Mar 29 02:00:00 UTC 2006
x --> Wed Mar 29 01:00:00 UTC 2006
y --> Wed Mar 29 00:00:00 UTC 2006

My use of "a year ago" is not really valid syntax, then. I was fooled by a lookalike! :-)

Dallman Ross <dman>
Wed 29 Mar 2006 12:13:55 PM UTC, original submission:

Two examples of valid syntax for date follows:

date -d "12:00 1 year ago"
date -d "12:00 a year ago"

The 'date' command acts as if it understands the indefinite article 'a' in this case. However, the time returned is off by one hour.

Sample output:

bash-3.00$ date --version | head -1
date (GNU sh-utils) 2.0

bash-3.00$ TZ=UTC

bash-3.00$ date -d "12:00 1 year ago"
Tue Mar 29 12:00:00 UTC 2005

bash-3.00$ date -d "12:00 a year ago"
Tue Mar 29 13:00:00 UTC 2005

bash-3.00$ date -d "12:00 a month ago"
Wed Mar 1 13:00:00 UTC 2006

bash-3.00$ date -d "12:00 next month"
Sat Apr 29 12:00:00 UTC 2006

bash-3.00$ date -d "12:00 a month ago next month" # today
Wed Mar 29 13:00:00 UTC 2006

--
Dallman Ross

Dallman Ross <dman>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 12 Apr 2006 08:20:56 PM UTCeggertOpen/ClosedOpen=>Closed
Wed 29 Mar 2006 12:13:55 PM UTCdmanCarbon-Copy-=>Added -unavailable-

Back to the top


Powered by Savane 3.1-cleanup1