[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Date doesn't like field separators
From:       Joshua Judson Rosen <jrosen () harvestai ! com>
Date:       2013-09-26 1:52:25
Message-ID: 52439359.1010302 () harvestai ! com
[Download RAW message or body]

On 2013-09-25 15:49, Jody Lee Bruchon wrote:
> I am using the date command to process dates from a text file in the typical \
> American "mm/dd/yyyy" format. The date command chokes if I pass such a date with -d \
> for reformatting; likewise, dashes aren't accepted at all either. I am having to \
> pipe through tr -d / before giving the date, but GNU coreutils 8.19 gladly accepts \
> the same date with separators. I'm confused by the code for date.c and I'm not \
> quite sure what to change to add compatibility, so I thought I should at least \
> mention it here. It may even be a bug in the code, since I see at least one strspn \
> call with 0123456789 as permissible characters. 
> While my script works with the tr command plugged in, it's a minor incompatibility \
> that I had to handle when moving a script from its GNU testing machine, and I \
> imagine I can't be the only one hit by it.

GNU coreutils' "date" command accepts a pretty astounding range of date-formats :)

Have you checked the output of busybox's "date --help"? The copy of busybox that 
I have on hand says:

	Recognized TIME formats:
		hh:mm[:ss]
		[YYYY.]MM.DD-hh:mm[:ss]
		YYYY-MM-DD hh:mm[:ss]
		[[[[[YY]YY]MM]DD]hh]mm[.ss]
		'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead

Also, it mentions a "-D FMT" option, which, if the strings you have are in 
"mm/dd/yyyy HH:MM:SS" format..., you should be able to make the date command 
parse them with:

	date -D '%m/%d/%Y %T' --date=...

Though it looks like "-D" is a nonstandard option--my copy of GNU date doesn't 
have it....


-- 
"'tis an ill wind that blows no minds."
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic