[Bug 198530] date(1) command: parsing of %T broken in 10.1-RELEASE
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Wed Mar 11 20:47:57 UTC 2015
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 at FreeBSD.org
Reporter: euan at 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.
More information about the freebsd-bugs
mailing list