Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Mar 2015 20:47:57 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 198530] date(1) command: parsing of %T broken in 10.1-RELEASE
Message-ID:  <bug-198530-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198530

            Bug ID: 198530
           Summary: date(1) command: parsing of %T broken in 10.1-RELEASE
           Product: Base System
           Version: 10.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: euan@potensol.com

The parsing of a date by date(1) using the -f flag and %T is now broken in
10.1-RELEASE.

I noticed it when my script that previous worked no longer does.

For example, in FreeBSD 10.0-RELEASE-p7:

$ date -j -f "%a %b %d %T %Y" "Thu Mar 12 3:08 2015" +%s
1426100897

But in FreeBSD 10.1-RELEASE-p0:

$ date -j -f "%a %b %d %T %Y" "Thu Mar 12 3:08 2015" +%s
Failed conversion of ``Thu Mar 12 3:08 2015'' using format ``%a %b %d %T %Y''
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

And from the man pages' example section, in FeeeBSD 10.1-RELEASE:

$ date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
Failed conversion of ``Thu 12 Mar 2015 04:28:16 SGT'' using format ``%a %b %d
%T %Z %Y''
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]



I may be able to workaround / fix my script by changing the %T to %H:%M, since
it seems it's the lack of the minutes that's upsetting the parser.

For example, in FreeBSD 10.1-RELEASE:

$ date -j -f "%a %b %d %H:%M %Y" "Thu Mar 12 3:08 2015" +%s
1426100907


The date string I'm using is from "zfs -H -o creation pool/filesytem". And the
reason the man page example doesn't work is probably the timezone. In my case
SGT. e.g:

$ date
Thu 12 Mar 2015 04:34:39 SGT

Perhaps the change is intentional, to make the parser more strict. But it's not
nice when a script gets broken. And the man page needs updating in any case.

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-198530-8>