NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/47596: parsedate() misparses 'last sunday -1 day'

>Number:         47596
>Category:       lib
>Synopsis:       parsedate() misparses 'last sunday -1 day'
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 25 20:25:00 +0000 2013
>Originator:     David Laight
>Release:        6.0
The parsedate() code (in libutil/parsedate.y) always processes the 'last 
sunday' after adjusting the current time for any relative time offsets.

This means that "date -d 'last sunday -5 days" reports the sunday before 5 days 
ago - not the intended tuesday of last week.

(Discovered when moving a small script from a different OS.)

date -d "@$(date -d 'last sunday' +%s) -5 days"

Rewrite the parser so that it modifies the time as it processes the input 
string (instead of trying to remember the fields and doing the work afterwards).

Home | Main Index | Thread Index | Old Index