Bug 198530 - date(1) command: parsing of %T broken in 10.1-RELEASE
Summary: date(1) command: parsing of %T broken in 10.1-RELEASE
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-11 20:47 UTC by Euan Thoms
Modified: 2015-03-11 20:47 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Euan Thoms 2015-03-11 20:47:57 UTC
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.