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

Submitter:  Dallman Ross <dman>
Submitted:  Wed 29 Mar 2006 12:13:55 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-04-12 eggert Open/ClosedOpen Closed
2006-03-29 dman Carbon-Copy- Added -email is unavailable-

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code