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

Re: [Was: Re: policy around 'wontfix' bug tag



On Tue 06 Feb 2018 at 12:32:06 (+1100), Erik Christiansen wrote:
> On 05.02.18 09:39, Greg Wooledge wrote:
> > On Sun, Feb 04, 2018 at 04:04:34PM +0100, Nicolas George wrote:
> > > All you describe is convenience for programmatic use. As I explained,
> > > this parser is meant for interactive use.
> > 
> > What on EARTH made you think THAT?
> 
> The fuzzy grammar of the date string makes programmatic use a bit
> empirical, I must admit.
> 
> > I promise you, people ARE using date -d '...' in shell scripts.
> > LOTS of people.  Hell, I've done it.(*)
> 
> A data point: I have been using "date" for a good 30 years, on hp-ux,
> SunOS, Solaris, and now linux - pretty much _exclusively_ in scripts,
> even with -d. An example still in use even scripts the "human readable"
> input:
> 
> #!/bin/bash
> [ `date '+%H'` -lt 4 ] && day="yesterday" || day="today"
> d="`date -d $day '+%a %b %_d'`"
> ...
> echo "`date -d $day '+%a %b %_d'`" $n >> ~/fetchmail_traffic
> 
> If a new formal grammar largely consistent with the "mostly free format
> human readable date string" were defined in the manpage, then that could
> be a step forward.

But how would you deal with the simplest (to express) problem of all,
that of

$ date -d 1/2/18
Tue Jan  2 00:00:00 CST 2018
$ 

which would mean a battery of locale-specific rules.

> And for the far past, cal is superior; compare:
> 
> $ cal -3 9 1752
>     August 1752          September 1752         October 1752      
> Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
>                    1         1  2 14 15 16   1  2  3  4  5  6  7  
>  2  3  4  5  6  7  8  17 18 19 20 21 22 23   8  9 10 11 12 13 14  
>  9 10 11 12 13 14 15  24 25 26 27 28 29 30  15 16 17 18 19 20 21  
> 16 17 18 19 20 21 22                        22 23 24 25 26 27 28  
> 23 24 25 26 27 28 29                        29 30 31              
> 30 31

That works for the British Empire at and since that time. In the years
before that, there are at least two problems with historic dates:

    some places had already moved onto the Gregorian calendar years
    earlier,

    for dates before Lady Day, you need to know if the recorded date
    was "Old Style" or "New Style", else you'll be off by one.

Cheers,
David.


Reply to: