bug#52525: wanted to add option to date command to handle pure numeric input in varying ways and output for invalid dates

2021-12-15 Thread Mike Marchywka
On Wed, Dec 15, 2021 at 02:09:29PM -0800, Paul Eggert wrote:
> On 12/15/21 12:39, Mike Marchywka wrote:
> > $echo 2000 | date +%Y -f-
> > 2021
> 
> How about this instead? The idea is to avoid
> adding features if they can easily be
> implemented with some other standard utility.
> This way, you can write your shell scripts now
> rather than waiting for a future fix (plus, it
> keeps 'date' simpler).
> 
> echo 2000 | sed 's/$/-07-01/' | date +%Y -f-
> 

That is great until the input format is -MM-DD :)
The point of using date was to get all the internal
stuff that deals with ambiguous formats and probably
a lot of other people do that too.  
The info documentation does point out how ambiguous
the human readable dates are. I guess 2000 could also
be ms since epoch. I am calling date from c++
and could just ias easily wrap it in another c++ program
to deal with this but thought it was of more general
interest and I did not want to make another kluge.

Generally I agree with your approach but if date is
going to be a swiss army knife for date conversions
it makes some sense to allow user selection of
ambiguity resolution doesn't it? 

Thanks. 




-- 

mike marchywka
306 charles cox
canton GA 30115
USA, Earth 
marchy...@hotmail.com
404-788-1216
ORCID: -0001-9237-455X





bug#52525: wanted to add option to date command to handle pure numeric input in varying ways and output for invalid dates

2021-12-15 Thread Paul Eggert

On 12/15/21 14:24, Mike Marchywka wrote:


if date is
going to be a swiss army knife for date conversions
it makes some sense to allow user selection of
ambiguity resolution doesn't it?


There are thousands of possible data conversions and I'm not sure we 
want to head down the road of trying to handle them all.


That being said, this particular conversion might be worth the trouble. 
However, 'date' uses the same date parser that a lot of other GNU 
programs do. Surely if there's a change to be made to date parsing it 
should be made there, not just to 'date', so that all the other programs 
can use the new functionality.






bug#52525: wanted to add option to date command to handle pure numeric input in varying ways and output for invalid dates

2021-12-15 Thread Paul Eggert

On 12/15/21 12:39, Mike Marchywka wrote:

$echo 2000 | date +%Y -f-
2021


How about this instead? The idea is to avoid adding features if they can 
easily be implemented with some other standard utility. This way, you 
can write your shell scripts now rather than waiting for a future fix 
(plus, it keeps 'date' simpler).


echo 2000 | sed 's/$/-07-01/' | date +%Y -f-






bug#52525: wanted to add option to date command to handle pure numeric input in varying ways and output for invalid dates

2021-12-15 Thread Mike Marchywka
I'm trying to implement the options shown below. I downloaded the coreutils 
source
for my distro and don't expect a problem compling and implementing it.
However, is there any interest in adding similar functions to the main code?

I would imagine something like,

date  --option=four-digits-are-,invalid-output-blank-line 

My immediate concern is getting this to take the input as a year rather than 
HHMM and
it would be easier to make date more versatile than put logic around it,

$echo 2000 | date +%Y -f-
2021

not sure if anyone else would want that.

Thanks. 



 Mike Marchywka 
306 Charles Cox Drive 
Canton, GA 30115
470-758-0799
404-788-1216 





From: Mike Marchywka
Sent: Wednesday, December 15, 2021 2:08 PM
To: coordina...@translationproject.org
Subject: the ubuntu "date" command info pointed me to you, question on 
modification

I wanted to add an option to the linux date command to
deal with pure number date stings - allowing for a 4 digit number
to be a year instead of HHMM - which should be easy
for me to do but I wanted to see how it integrates.
Also, I wanted an output option, that I could write, to
send an invalid message to stdout instead of stderr.

How should I proceed?

Thanks.


 Mike Marchywka
306 Charles Cox Drive
Canton, GA 30115
470-758-0799
404-788-1216